﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Odbc;
using System.Data.OracleClient;
using System.Configuration;
using CVSA.Suporte.Sinacor.BMFBovespa.Entidades;
using System.IO;



using System.Diagnostics;
using CVSA.Suporte.Sinacor.BMFBovespa.Dados.HelpDesk_Submit_Service;

namespace CVSA.Suporte.Sinacor.BMFBovespa.Dados
{
    public class Remedy
    {
        private string connString = ConfigurationManager.ConnectionStrings["connStringSqlRemedy"].ToString();
        private string remedyUserName = ConfigurationManager.AppSettings["remedyUserName"].ToString();
        private string remedyPassword = ConfigurationManager.AppSettings["remedyPassword"].ToString();
        private string proxyServer = ConfigurationManager.AppSettings["proxyServer"].ToString();


        public void SincronizarRemedy(List<Chamado> Chamados)
        {
            OracleConnection conn = new OracleConnection(connString);
            OracleCommand commandExisteChamado = new OracleCommand();
            commandExisteChamado.CommandType = CommandType.Text;

            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;
            command.Connection = conn;

            commandExisteChamado.Connection = conn;
            commandExisteChamado.Parameters.Add("IdIncidente", OracleType.Char);

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                foreach (Chamado chamado in Chamados)
                {

                    // se for novo
                    commandExisteChamado.Parameters["IdIncidente"].Value = chamado.IdIncidente;
                    commandExisteChamado.CommandText = "Select 1 from Tb_Chamados Where IdIncidente = :IdIncidente";
                    int existeChamado = Convert.ToInt32(commandExisteChamado.ExecuteScalar());

                    #region  tratamento dos dados
                    if (existeChamado == 0)
                    {


                        command.Parameters.AddWithValue("IdIncidente", chamado.IdIncidente);
                        command.Parameters.AddWithValue("Empresa", chamado.Empresa);
                        command.Parameters.AddWithValue("Prioridade", chamado.Prioridade);
                        command.Parameters.AddWithValue("Status", chamado.Status);



                        command.Parameters.AddWithValue("Descricao", chamado.Descricao);

                        if (chamado.Resolucao != null)
                        {
                            command.Parameters.AddWithValue("Resolucao", chamado.Resolucao);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Resolucao", string.Empty);
                        }


                        if (chamado.Detalhe != null)
                        {
                            command.Parameters.AddWithValue("Detalhe", chamado.Detalhe);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Detalhe", string.Empty);
                        }


                        command.Parameters.AddWithValue("DataAbertura", chamado.Data_Abertura);
                        command.Parameters.AddWithValue("AreaDesignada", chamado.Area_Designada);
                        command.Parameters.AddWithValue("DataAplicacao", DateTime.Today);
                        command.Parameters.AddWithValue("DataAplicacao1", DateTime.Today);
                        command.Parameters.AddWithValue("DtUltimaInteracao", chamado.DtUltimaInteracao);

                        if (chamado.DtFechamento != DateTime.MinValue)
                        {
                            command.Parameters.AddWithValue("DtFechamento", chamado.DtFechamento);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("DtFechamento", DBNull.Value);
                        }

                        if (chamado.DtRequerida != DateTime.MinValue)
                        {
                            command.Parameters.AddWithValue("DtRequerida", chamado.DtRequerida);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("DtRequerida", DBNull.Value);
                        }

                        if (chamado.DtEstimada != DateTime.MinValue)
                        {
                            command.Parameters.AddWithValue("DtEstimada", chamado.DtEstimada);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("DtEstimada", DBNull.Value);
                        }


                        if (!String.IsNullOrEmpty(chamado.Pessoa_Designada))
                        {
                            command.Parameters.AddWithValue("Pessoa_Designada", chamado.Pessoa_Designada);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Pessoa_Designada", string.Empty);
                        }

                        if (!String.IsNullOrEmpty(chamado.TipoChamado))
                        {
                            command.Parameters.AddWithValue("Tipo_Chamado", chamado.TipoChamado);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Tipo_Chamado", string.Empty);
                        }

                        command.CommandText = "INSERT INTO Tb_Chamados (IdIncidente, Empresa,Prioridade, Status, Descricao, Resolucao, Detalhe, Data_Abertura, Area_Designada, DTULTIMAINTERACAO, DTINSERCAO, DTATUALIZACAO, DTFECHAMENTO, Pessoa_Designada, Tipo_Chamado, DtRequerida, DtEstimada) " + 
                                                              " VALUES (:IdIncidente, :Empresa, :Prioridade, :Status, :Descricao, :Resolucao, :Detalhe, :DataAbertura, :AreaDesignada, :DtUltimaInteracao, :DataAplicacao, :DataAplicacao1, :DtFechamento, :Pessoa_Designada, :Tipo_Chamado, :DtRequerida, :DtEstimada)";

                    }
                    else
                    {
                        // se existir

                        command.Parameters.AddWithValue("Empresa", chamado.Empresa);
                        command.Parameters.AddWithValue("Prioridade", chamado.Prioridade);
                        command.Parameters.AddWithValue("Status", chamado.Status);
                        command.Parameters.AddWithValue("Descricao", chamado.Descricao);

                        if (!String.IsNullOrEmpty(chamado.Resolucao))
                        {
                            command.Parameters.AddWithValue("Resolucao", chamado.Resolucao);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Resolucao", string.Empty);
                        }



                        if (!String.IsNullOrEmpty(chamado.Detalhe))
                        {
                            command.Parameters.AddWithValue("Detalhe", chamado.Detalhe);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Detalhe", string.Empty);
                        }




                        command.Parameters.AddWithValue("DataAbertura", chamado.Data_Abertura);
                        command.Parameters.AddWithValue("AreaDesignada", chamado.Area_Designada);
                        command.Parameters.AddWithValue("DataAplicacao", DateTime.Today);

                        command.Parameters.AddWithValue("DtUltimaInteracao", chamado.DtUltimaInteracao);

                        if (chamado.DtFechamento != DateTime.MinValue)
                        {
                            command.Parameters.AddWithValue("DtFechamento", chamado.DtFechamento);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("DtFechamento", DBNull.Value);
                        }

                        if (chamado.DtRequerida != DateTime.MinValue)
                        {
                            command.Parameters.AddWithValue("DtRequerida", chamado.DtRequerida);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("DtRequerida", DBNull.Value);
                        }

                        if (chamado.DtEstimada != DateTime.MinValue)
                        {
                            command.Parameters.AddWithValue("DtEstimada", chamado.DtEstimada);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("DtEstimada", DBNull.Value);
                        }

                        command.Parameters.AddWithValue("IdIncidente", chamado.IdIncidente);

                        if (!String.IsNullOrEmpty(chamado.Pessoa_Designada))
                        {
                            command.Parameters.AddWithValue("Pessoa_Designada", chamado.Pessoa_Designada);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Pessoa_Designada", string.Empty);
                        }

                        if (!String.IsNullOrEmpty(chamado.TipoChamado))
                        {
                            command.Parameters.AddWithValue("Tipo_Chamado", chamado.TipoChamado);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Tipo_Chamado", string.Empty);
                        }


                        command.CommandText = "UPDATE Tb_Chamados SET ";
                        command.CommandText += " Empresa = :Empresa, ";
                        command.CommandText += " Prioridade = :Prioridade, ";
                        command.CommandText += " Status = :Status, ";
                        command.CommandText += " Descricao = :Descricao,  ";
                        command.CommandText += " Resolucao = :Resolucao,";
                        command.CommandText += " Detalhe = :Detalhe, ";
                        command.CommandText += " Data_Abertura = :DataAbertura, ";
                        command.CommandText += " Area_Designada = :AreaDesignada, ";
                        command.CommandText += " DtAtualizacao = :DataAplicacao,";
                        command.CommandText += " DtUltimaInteracao = :DtUltimaInteracao, ";
                        command.CommandText += " DtFechamento = :DtFechamento, ";
                        command.CommandText += " DtRequerida = :DtRequerida, ";
                        command.CommandText += " DtEstimada = :DtEstimada, ";
                        command.CommandText += " Pessoa_Designada= :Pessoa_Designada,";
                        command.CommandText += " Tipo_Chamado= :Tipo_Chamado";
                        command.CommandText += " WHERE IdIncidente = :IdIncidente   ";

                    }

                    #endregion


                    try
                    {
                        command.Prepare();
                        command.ExecuteNonQuery();
                        command.Parameters.Clear();
                    }
                    catch (Exception ex)
                    {
                        string e = ex.Message + " - " + ex.InnerException;
                    }
                }
            }

            finally
            {
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }
                command.Dispose();
                conn.Dispose();
            }

        }

        public DateTime UltimoSincronismo()
        {
            OracleConnection conn = new OracleConnection(connString);
            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;
            command.Connection = conn;
            command.CommandText = "Select Max (DtUltimaInteracao) from Tb_Chamados";
            DateTime ultimoRegistro = new DateTime(2009, 1, 1);
            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                string _ultimoRegistro = Convert.ToString(command.ExecuteScalar());
                if (!String.IsNullOrEmpty(_ultimoRegistro))
                {
                    ultimoRegistro = Convert.ToDateTime(_ultimoRegistro);
                }

            }
            finally
            {
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }
                command.Dispose();
                conn.Dispose();
            }
            return ultimoRegistro;
        }

        public DataTable ObterDadosTemp(int? Status)
        {
            DataTable odt = new DataTable("Tb_Chamados");
            OracleConnection conn = new OracleConnection(connString);

            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;
            string sqlcommand = string.Empty;

            if (Status == 1)
            {
                sqlcommand = "SELECT * FROM Tb_Chamados WHERE Status In ('In Progress', 'InProgress','Pending', 'Assigned') Order By Data_Abertura DESC";
            }
            else if (Status == 0)
            {
                sqlcommand = "SELECT * FROM Tb_Chamados WHERE Status In ('Closed', 'Resolved', 'Cancelled') Order By Data_Abertura DESC";
            }
            else
            {
                sqlcommand = "SELECT * FROM Tb_Chamados Order By Data_Abertura DESC";
            }


            command.CommandText = sqlcommand;
            command.Connection = conn;

            OracleDataAdapter da = new OracleDataAdapter(command);

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                da.Fill(odt);

                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }

            }
            catch (OracleException ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
            finally
            {

                da.Dispose();
                command.Dispose();
                conn.Dispose();
            }

            return odt;
        }

        public DataTable ObterDadosDB(string clause)
        {
            DataTable odt = new DataTable("Tb_Chamados");
            OracleConnection conn = new OracleConnection(connString);

            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;
            string sqlcommand = string.Empty;


            sqlcommand = "SELECT * FROM Tb_Chamados " + clause + " Order By Data_Abertura DESC";

            command.CommandText = sqlcommand;
            command.Connection = conn;

            OracleDataAdapter da = new OracleDataAdapter(command);

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                da.Fill(odt);

                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }

            }
            catch (OracleException ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
            finally
            {

                da.Dispose();
                command.Dispose();
                conn.Dispose();
            }

            return odt;
        }

        public DataTable ObterPrioridadeChamados()
        {
            string strQuery = "select distinct prioridade from TB_CHAMADOS order by Prioridade";

            DataTable odt = new DataTable("Tb_PrioridadeChamados");
            OracleConnection conn = new OracleConnection(connString);

            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;

            command.CommandText = strQuery;
            command.Connection = conn;

            OracleDataAdapter da = new OracleDataAdapter(command);

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                da.Fill(odt);

                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }

            }
            catch (OracleException ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
            finally
            {

                da.Dispose();
                command.Dispose();
                conn.Dispose();
            }

            return odt;

        }

        public DataTable ObterAreasChamados()
        {
            string strQuery = "select distinct Area_Designada from TB_CHAMADOS Where Area_Designada NOT IN ('DO-CGAS-ATEND SINACOR','DO-CICF-SISTEMAS / APLICATIVOS','DO-CSSA-ANALISTAS CSSA','DO-CVSA-DEMANDAS', 'DO-CGAS-ATEND CLIENTES') And Status In ('In Progress', 'InProgress','Pending', 'Assigned') order by Area_Designada";

            DataTable odt = new DataTable("Tb_AreaChamados");
            OracleConnection conn = new OracleConnection(connString);

            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;

            command.CommandText = strQuery;
            command.Connection = conn;

            OracleDataAdapter da = new OracleDataAdapter(command);

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                da.Fill(odt);

                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }

            }
            catch (OracleException ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
            finally
            {

                da.Dispose();
                command.Dispose();
                conn.Dispose();
            }

            return odt;

        }

        public List<Chamado> getIncidentsWS(string Classification, string username, string passwd)
        {
            remedyWS.ITPAM_HPD_HelpDesk_WSService obj = new remedyWS.ITPAM_HPD_HelpDesk_WSService();
            remedyWS.AuthenticationInfo AuthenticationInfoValue = new remedyWS.AuthenticationInfo();

            if (!string.IsNullOrEmpty(username))
            {
                AuthenticationInfoValue.userName = username;
                AuthenticationInfoValue.password = passwd;
            }
            else
            {
                AuthenticationInfoValue.userName = remedyUserName;
                AuthenticationInfoValue.password = Tools.Decrypt(remedyPassword, true);
            }
            obj.AuthenticationInfoValue = AuthenticationInfoValue;
            obj.Timeout = 999999999;

            System.Net.WebProxy proxy = new System.Net.WebProxy(proxyServer, 80);
            System.Net.NetworkCredential cred = new System.Net.NetworkCredential();
            cred.Domain = "corporate";
            cred.UserName = AuthenticationInfoValue.userName;
            cred.Password = AuthenticationInfoValue.password;
            proxy.Credentials = cred;
            obj.Proxy = proxy;

            remedyWS.GetListOutputMapGetListValues[] dsresult;
            dsresult = obj.HelpDesk_GetList(Classification, "0", string.Empty);

            List<Chamado> chamados = new List<Chamado>();

            foreach (remedyWS.GetListOutputMapGetListValues item in dsresult)
            {
                Chamado chamado = new Chamado();
                chamado.Area_Designada = item.Assigned_Group;
                chamado.Data_Abertura = Convert.ToDateTime(item.Submit_Date);
                chamado.Descricao = item.Description;
                chamado.Detalhe = item.Detailed_Decription;
                chamado.DtAtualizacao = DateTime.Now;
                if (!String.IsNullOrEmpty(item.Last_Resolved_Date))
                {
                    chamado.DtFechamento = Convert.ToDateTime(item.Last_Resolved_Date);
                }

                if (!String.IsNullOrEmpty(item.Required_Resolution_DateTime))
                {
                    chamado.DtRequerida = Convert.ToDateTime(item.Required_Resolution_DateTime);
                }

                if (!String.IsNullOrEmpty(item.Estimated_Resolution_Date))
                {
                    chamado.DtEstimada = Convert.ToDateTime(item.Estimated_Resolution_Date);
                }

                chamado.DtInsercao = DateTime.Now;
                chamado.DtUltimaInteracao = Convert.ToDateTime(item.Last_Modified_Date);
                chamado.Empresa = item.Company;
                chamado.IdIncidente = item.Incident_Number;
                chamado.Prioridade = item.Priority.ToString();
                chamado.Resolucao = item.Resolution;
                chamado.Status = item.Status.ToString();
                chamado.Pessoa_Designada = item.Assignee;
                chamado.TipoChamado = item.Categorization_Tier_1;
                chamados.Add(chamado);

            }
            return chamados;

        }

        public List<Chamado> getIncidentsOdbc(string Classification)
        {

            DateTime ultimoSincronismo = UltimoSincronismo().AddDays(-2);
            string ultimaAtualizacao = ultimoSincronismo.Year + "-" + ultimoSincronismo.Month.ToString("00") + "-" + ultimoSincronismo.Day.ToString("00");

            string p = @"SELECT  ""HPD_Help_Desk"".""Submit_Date"", 
                                 ""HPD_Help_Desk"".""Status"", 
                                 ""HPD_Help_Desk"".""Assigned_Group"", 
                                 ""HPD_Help_Desk"".""Assignee"", 
                                 ""HPD_Help_Desk"".""Incident_Number"", 
                                 ""HPD_Help_Desk"".""Closed_Date"" ,
                                 ""HPD_Help_Desk"".""Configuration_Item"",
                                 ""HPD_Help_Desk"".""Last_Resolved_Date"",
                                 ""HPD_Help_Desk"".""CATEGORIZATION_TIER_1"",
                                 ""HPD_Help_Desk"".""CATEGORIZATION_TIER_2"",
                                 ""HPD_Help_Desk"".""CATEGORIZATION_TIER_3"",
                                 ""HPD_Help_Desk"".""GENERIC_CATEGORIZATION_TIER_1"",
                                 ""HPD_Help_Desk"".""GENERIC_CATEGORIZATION_TIER_2"",
                                 ""HPD_Help_Desk"".""GENERIC_CATEGORIZATION_TIER_3"",
                                 ""HPD_Help_Desk"".""PRIORITY"",
                                 ""HPD_Help_Desk"".""COMPANY"",
                                 ""HPD_Help_Desk"".""DESCRIPTION"",
                                 ""HPD_Help_Desk"".""DETAILED_DECRIPTION"",
                                 ""HPD_Help_Desk"".""Last_Modified_Date"",
                                 ""HPD_Help_Desk"".""Resolution"",
                                 ""HPD_Help_Desk"".""Required_Resolution_DateTime"", 
                                 ""HPD_Help_Desk"".""Estimated_Resolution_Date""
                    FROM   ""HPD_Help_Desk"" ""HPD_Help_Desk"" 
                    WHERE  ""HPD_Help_Desk"".""Assigned_Group"" LIKE 'DO-DSE-SUPORTE%' 
                    AND ""HPD_Help_Desk"".""Last_Modified_Date"" > {ts '" + ultimaAtualizacao + @" 00:00:00'}";


            OdbcConnection cmd = new OdbcConnection("Dsn=AR System ODBC Data Source;arserver=arscorp1;arserverport=50001;UID=" + ConfigurationManager.AppSettings["remedyUserName"] + ";PWD=" + Tools.Decrypt(ConfigurationManager.AppSettings["remedyPassword"], true) + ";aruseunderscores=1;arnamereplace=1;server=NotTheServer");
            OdbcDataAdapter da = new OdbcDataAdapter(p, cmd);

            da = new OdbcDataAdapter(p, cmd);
            DataSet dsTotal = new DataSet();
            da.Fill(dsTotal);


            List<Chamado> chamados = new List<Chamado>();

            foreach (DataRow item in dsTotal.Tables[0].Rows)
            {
                Chamado chamado = new Chamado();
                chamado.Area_Designada = item["Assigned_Group"].ToString();
                chamado.Data_Abertura = Convert.ToDateTime(item["Submit_Date"]);
                chamado.Descricao = item["DESCRIPTION"].ToString();
                chamado.Detalhe = item["DETAILED_DECRIPTION"].ToString();
                chamado.DtAtualizacao = DateTime.Now;
                if (!String.IsNullOrEmpty(item["Last_Resolved_Date"].ToString()))
                {
                    chamado.DtFechamento = Convert.ToDateTime(item["Last_Resolved_Date"]);
                }

                if (!String.IsNullOrEmpty(item["Required_Resolution_DateTime"].ToString()))
                {
                    chamado.DtRequerida = Convert.ToDateTime(item["Required_Resolution_DateTime"]);
                }

                if (!String.IsNullOrEmpty(item["Estimated_Resolution_Date"].ToString()))
                {
                    chamado.DtEstimada = Convert.ToDateTime(item["Estimated_Resolution_Date"]);
                }

                chamado.DtInsercao = DateTime.Now;
                chamado.DtUltimaInteracao = Convert.ToDateTime(item["Last_Modified_Date"]);
                chamado.Empresa = item["Company"].ToString();
                chamado.IdIncidente = item["Incident_Number"].ToString();
                chamado.Prioridade = item["Priority"].ToString();
                chamado.Resolucao = item["Resolution"].ToString();
                chamado.Status = item["Status"].ToString();
                chamado.Pessoa_Designada = item["Assignee"].ToString();
                chamado.TipoChamado = item["CATEGORIZATION_TIER_1"].ToString();
                chamados.Add(chamado);

            }
            return chamados;

        }

        public DataTable getChamadosForcatarefa(string dtInicio, string dtFim)
        {
//            string strQuery = @"select trunc(a.DtFechamento) DataFechamento,
//                               sum( decode( Pessoa_Designada, 'Patricia A Nacamura', 1, 0 ) ) Patricia
//                               , sum( decode( Pessoa_Designada, 'Alessandra A Oliveira', 1, 0 ) ) Alessandra
//                               , sum( decode( Pessoa_Designada, 'Aline Diegas Russo', 1, 0 ) ) Aline
//                               , sum( decode( Pessoa_Designada, 'Paula Roberta Biasin', 1, 0 ) ) Paula
//                               , sum( decode( Pessoa_Designada, 'Elen Hatsue Kodama', 1, 0 ) ) Elen
//                               , sum( decode( Pessoa_Designada, 'Matheus Malagoli Thereza', 1, 0 ) ) Matheus
//                               , sum( decode( Pessoa_Designada, 'Fabio Jose Silva', 1, 0 ) ) FabioJS
//                               , sum( decode( Pessoa_Designada, 'Valdemar Borba', 1, 0 ) ) Valdemar
//                               , sum( decode( Pessoa_Designada, 'Mauricio Bastos', 1, 0 ) ) Mauricio
//                               , sum( decode( Pessoa_Designada, 'Felipe Moreira Silverio', 1, 0 ) ) Felipe
//                               , sum( decode( Pessoa_Designada, 'Cristiane Gomes Silva', 1, 0 ) ) Cristiane
//                               from Tb_Chamados a
//                               Where a.DtFechamento >= to_date('" + dtInicio + @"' , 'DD/MM/YYYY')
//                               and trunc(a.DtFechamento) <= to_date('" + dtFim + @"' , 'DD/MM/YYYY')
//                               Group By trunc(DtFechamento)
//                               Order By DataFechamento";


            string strQuery = @" SELECT  PESSOA_DESIGNADA, SUM(QTD_FEC) QTD_FEC,  trunc(DTFECHAMENTO) DIA  FROM 
                        (
                        
                          SELECT 	
                          PESSOA_DESIGNADA, COUNT(1) QTD_FEC  ,  trunc(DTFECHAMENTO) DTFECHAMENTO
                          FROM TB_CHAMADOS WHERE STATUS IN ('Closed', 'Resolved')  
                          AND AREA_DESIGNADA = 'DO-DSE-SUPORTE NIVEL 1'
                          AND	DtFechamento >= to_date('" + dtInicio + @"' , 'DD/MM/YYYY')
                          and trunc(DtFechamento) <= to_date('" + dtFim + @"' , 'DD/MM/YYYY')
                          GROUP BY trunc(DTFECHAMENTO), PESSOA_DESIGNADA
                        )
                        GROUP BY trunc(DTFECHAMENTO), PESSOA_DESIGNADA
                        ORDER by PESSOA_DESIGNADA, DIA
                        ";


            DataTable odt = new DataTable("Tb_Chamados");
            OracleConnection conn = new OracleConnection(connString);

            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;

            command.CommandText = strQuery;
            command.Connection = conn;

            OracleDataAdapter da = new OracleDataAdapter(command);

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                da.Fill(odt);

                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }

            }
            catch (OracleException ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
            finally
            {

                da.Dispose();
                command.Dispose();
                conn.Dispose();
            }

            return odt;


        }

        public DataTable getCesta()
        {

            string query = @"
                        SELECT trunc(DTFECHAMENTO) DTFECHAMENTO, PESSOA_DESIGNADA, SUM(QTD_FEC) QTD_FEC  FROM 
                        (
                        
                          SELECT 	
                          trunc(DTFECHAMENTO) DTFECHAMENTO, PESSOA_DESIGNADA, COUNT(1) QTD_FEC  
                          FROM TB_CHAMADOS WHERE STATUS IN ('Closed', 'Resolved')  
                          AND AREA_DESIGNADA = 'DO-DSE-SUPORTE NIVEL 1'
                          AND	TRUNC(DTFECHAMENTO) = TRUNC(SYSDATE) 
                          GROUP BY trunc(DTFECHAMENTO), PESSOA_DESIGNADA
                        )
                        GROUP BY trunc(DTFECHAMENTO), PESSOA_DESIGNADA
                        ORDER BY DTFECHAMENTO, PESSOA_DESIGNADA
                        ";
            DataTable odt = new DataTable("Tb_Cesta");
            OracleConnection conn = new OracleConnection(connString);

            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;

            command.CommandText = query;
            command.Connection = conn;

            OracleDataAdapter da = new OracleDataAdapter(command);

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                da.Fill(odt);

                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }

            }
            catch (OracleException ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
            finally
            {

                da.Dispose();
                command.Dispose();
                conn.Dispose();
            }

            return odt;


        }

        public DataTable getPeriodos()
        {
            string query = @"select distinct to_char(a.DtFechamento,'mm/yyyy') DataFechamento
                            from tb_chamados a 
                             where DtFechamento is not null order by to_date(DataFechamento, 'mm/yyyy')  desc";
            DataTable odt = new DataTable("Tb_Periodo");
            OracleConnection conn = new OracleConnection(connString);

            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;

            command.CommandText = query;
            command.Connection = conn;

            OracleDataAdapter da = new OracleDataAdapter(command);

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                da.Fill(odt);

                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }

            }
            catch (OracleException ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
            finally
            {

                da.Dispose();
                command.Dispose();
                conn.Dispose();
            }

            return odt;


        }

        public DataTable ObterDadosOciosos()
        {
            DataTable odt = new DataTable("Tb_Chamados");
            OracleConnection conn = new OracleConnection(connString);

            OracleCommand command = new OracleCommand();
            command.CommandType = CommandType.Text;
            string sqlcommand = string.Empty;

            sqlcommand = "SELECT IdIncidente FROM Tb_Chamados WHere Status In ('In Progress', 'InProgress','Pending', 'Assigned') ";
            //sqlcommand = "SELECT IdIncidente FROM Tb_Chamados WHere trunc(Data_Abertura) >=  to_date('20/06/2010', 'dd/MM/yyyy')";

            command.CommandText = sqlcommand;
            command.Connection = conn;

            OracleDataAdapter da = new OracleDataAdapter(command);

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                da.Fill(odt);

                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }

            }
            catch (OracleException ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
            finally
            {

                da.Dispose();
                command.Dispose();
                conn.Dispose();
            }

            return odt;
        }

        public DataSet ObterDadosPersonalizados(string Classification)
        {

            DataSet odt = new DataSet();
            remedyWS.ITPAM_HPD_HelpDesk_WSService obj = new remedyWS.ITPAM_HPD_HelpDesk_WSService();
            remedyWS.AuthenticationInfo AuthenticationInfoValue = new remedyWS.AuthenticationInfo();

            AuthenticationInfoValue.userName = remedyUserName;
            AuthenticationInfoValue.password = Tools.Decrypt(remedyPassword, true);
            obj.AuthenticationInfoValue = AuthenticationInfoValue;
            obj.Timeout = 999999999;

            //string strQuery = @"'Assigned Group' LIKE ""DO-CVSA%""";
            remedyWS.GetListOutputMapGetListValues[] dsresult;
            dsresult = obj.HelpDesk_GetList(Classification, "0", string.Empty);

            List<Chamado> chamados = new List<Chamado>();

            //foreach (remedyWS.GetListOutputMapGetListValues item in dsresult)
            //{
            //    Chamado chamado = new Chamado();
            //    chamado.Area_Designada = item.Assigned_Group;
            //    chamado.Data_Abertura = Convert.ToDateTime(item.Submit_Date);
            //    chamado.Descricao = item.Description;
            //    chamado.Detalhe = item.Detailed_Decription;
            //    chamado.DtAtualizacao = DateTime.Now;
            //    if (!String.IsNullOrEmpty(item.Last_Resolved_Date))
            //    {
            //        chamado.DtFechamento = Convert.ToDateTime(item.Last_Resolved_Date);
            //    }
            //    chamado.DtInsercao = DateTime.Now;
            //    chamado.DtUltimaInteracao = Convert.ToDateTime(item.Last_Modified_Date);
            //    chamado.Empresa = item.Company;
            //    chamado.IdIncidente = item.Incident_Number;
            //    chamado.Prioridade = item.Priority.ToString();
            //    chamado.Resolucao = item.Resolution;
            //    chamado.Status = item.Status.ToString();
            //    chamado.Pessoa_Designada = item.Assignee;
            //    chamados.Add(chamado);


            //}
            odt = ConvertToDataSet.ToDataSet<remedyWS.GetListOutputMapGetListValues>(dsresult);
            return odt;
        }

        public void AtualizarChamadosOciosos(DataTable Chamados)
        {

            foreach (DataRow row in Chamados.Rows)
            {
                string Classification = @"'Incident Number' = """ + row["IdIncidente"].ToString() + @"""";

                remedyWS.ITPAM_HPD_HelpDesk_WSService obj = new remedyWS.ITPAM_HPD_HelpDesk_WSService();
                remedyWS.AuthenticationInfo AuthenticationInfoValue = new remedyWS.AuthenticationInfo();

                AuthenticationInfoValue.userName = remedyUserName;
                AuthenticationInfoValue.password = Tools.Decrypt(remedyPassword, true);
                obj.AuthenticationInfoValue = AuthenticationInfoValue;
                obj.Timeout = 999999999;

                System.Net.WebProxy proxy = new System.Net.WebProxy(proxyServer, 80);
                System.Net.NetworkCredential cred = new System.Net.NetworkCredential();
                cred.Domain = "corporate";
                cred.UserName = AuthenticationInfoValue.userName;
                cred.Password = AuthenticationInfoValue.password;
                proxy.Credentials = cred;
                obj.Proxy = proxy;

                remedyWS.GetListOutputMapGetListValues[] dsresult;
                try
                {
                    dsresult = obj.HelpDesk_GetList(Classification, "0", string.Empty);


                    foreach (remedyWS.GetListOutputMapGetListValues item in dsresult)
                    {
                        Chamado chamado = new Chamado();
                        chamado.Area_Designada = item.Assigned_Group;
                        chamado.Data_Abertura = Convert.ToDateTime(item.Submit_Date);
                        chamado.Descricao = item.Description;
                        chamado.Detalhe = item.Detailed_Decription;
                        chamado.DtAtualizacao = DateTime.Now;
                        if (!String.IsNullOrEmpty(item.Last_Resolved_Date))
                        {
                            chamado.DtFechamento = Convert.ToDateTime(item.Last_Resolved_Date);
                        }

                        if (!String.IsNullOrEmpty(item.Required_Resolution_DateTime))
                        {
                            chamado.DtRequerida = Convert.ToDateTime(item.Required_Resolution_DateTime);
                        }

                        if (!String.IsNullOrEmpty(item.Estimated_Resolution_Date))
                        {
                            chamado.DtEstimada = Convert.ToDateTime(item.Estimated_Resolution_Date);
                        }

                        chamado.DtInsercao = DateTime.Now;
                        chamado.DtUltimaInteracao = Convert.ToDateTime(item.Last_Modified_Date);
                        chamado.Empresa = item.Company;
                        chamado.IdIncidente = item.Incident_Number;
                        chamado.Prioridade = item.Priority.ToString();
                        chamado.Resolucao = item.Resolution;
                        chamado.Status = item.Status.ToString();
                        chamado.Pessoa_Designada = item.Assignee;
                        chamado.TipoChamado = item.Categorization_Tier_1;

                        // Atulizar base 

                        OracleConnection conn = new OracleConnection(connString);
                        OracleCommand commandExisteChamado = new OracleCommand();
                        commandExisteChamado.CommandType = CommandType.Text;

                        OracleCommand command = new OracleCommand();
                        command.CommandType = CommandType.Text;
                        command.Connection = conn;

                        commandExisteChamado.Connection = conn;

                        command.Parameters.AddWithValue("IdIncidente", chamado.IdIncidente);
                        command.Parameters.AddWithValue("Empresa", chamado.Empresa);
                        command.Parameters.AddWithValue("Prioridade", chamado.Prioridade);
                        command.Parameters.AddWithValue("Status", chamado.Status);
                        command.Parameters.AddWithValue("Descricao", chamado.Descricao);

                        if (!String.IsNullOrEmpty(chamado.Resolucao))
                        {
                            command.Parameters.AddWithValue("Resolucao", chamado.Resolucao);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Resolucao", string.Empty);
                        }



                        if (!String.IsNullOrEmpty(chamado.Detalhe))
                        {
                            command.Parameters.AddWithValue("Detalhe", chamado.Detalhe);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Detalhe", string.Empty);
                        }


                        command.Parameters.AddWithValue("DataAbertura", chamado.Data_Abertura);
                        command.Parameters.AddWithValue("AreaDesignada", chamado.Area_Designada);
                        command.Parameters.AddWithValue("DataAplicacao", DateTime.Today);

                        command.Parameters.AddWithValue("DtUltimaInteracao", chamado.DtUltimaInteracao);

                        if (chamado.DtFechamento != DateTime.MinValue)
                        {
                            command.Parameters.AddWithValue("DtFechamento", chamado.DtFechamento);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("DtFechamento", DBNull.Value);
                        }

                        if (chamado.DtRequerida != DateTime.MinValue)
                        {
                            command.Parameters.AddWithValue("DtRequerida", chamado.DtRequerida);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("DtRequerida", DBNull.Value);
                        }

                        if (chamado.DtEstimada != DateTime.MinValue)
                        {
                            command.Parameters.AddWithValue("DtEstimada", chamado.DtEstimada);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("DtEstimada", DBNull.Value);
                        }

                        command.Parameters.AddWithValue("IdIncidente", chamado.IdIncidente);

                        if (!String.IsNullOrEmpty(chamado.Pessoa_Designada))
                        {
                            command.Parameters.AddWithValue("Pessoa_Designada", chamado.Pessoa_Designada);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Pessoa_Designada", string.Empty);
                        }

                        if (!String.IsNullOrEmpty(chamado.TipoChamado))
                        {
                            command.Parameters.AddWithValue("Tipo_Chamado", chamado.TipoChamado);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("Tipo_Chamado", string.Empty);
                        }

                        command.CommandText = "UPDATE Tb_Chamados SET ";
                        command.CommandText += " Empresa = :Empresa, ";
                        command.CommandText += " Prioridade = :Prioridade, ";
                        command.CommandText += " Status = :Status, ";
                        command.CommandText += " Descricao = :Descricao,  ";
                        command.CommandText += " Resolucao = :Resolucao,";
                        command.CommandText += " Detalhe = :Detalhe, ";
                        command.CommandText += " Data_Abertura = :DataAbertura, ";
                        command.CommandText += " Area_Designada = :AreaDesignada, ";
                        command.CommandText += " DtAtualizacao = :DataAplicacao,";
                        command.CommandText += " DtUltimaInteracao = :DtUltimaInteracao, ";
                        command.CommandText += " DtFechamento = :DtFechamento, ";
                        command.CommandText += " DtRequerida = :DtRequerida, ";
                        command.CommandText += " DtEstimada = :DtEstimada, ";
                        command.CommandText += " Pessoa_Designada= :Pessoa_Designada, ";
                        command.CommandText += " Tipo_Chamado= :Tipo_Chamado";
                        command.CommandText += " WHERE IdIncidente = :IdIncidente   ";
                        conn.Open();
                        command.Prepare();
                        command.ExecuteNonQuery();
                        command.Parameters.Clear();
                        conn.Close();

                    }
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

        }

        public Chamado detalheChamadoBD(string idIncidente)
        {
            remedyWS.ITPAM_HPD_HelpDesk_WSService obj = new remedyWS.ITPAM_HPD_HelpDesk_WSService();
            remedyWS.AuthenticationInfo AuthenticationInfoValue = new remedyWS.AuthenticationInfo();

            AuthenticationInfoValue.userName = remedyUserName;
            AuthenticationInfoValue.password = Tools.Decrypt(remedyPassword, true);
            obj.AuthenticationInfoValue = AuthenticationInfoValue;
            obj.Timeout = 999999999;

            System.Net.WebProxy proxy = new System.Net.WebProxy(proxyServer, 80);
            System.Net.NetworkCredential cred = new System.Net.NetworkCredential();
            cred.Domain = "corporate";
            cred.UserName = AuthenticationInfoValue.userName;
            cred.Password = AuthenticationInfoValue.password;
            proxy.Credentials = cred;
            obj.Proxy = proxy;

            string Classification = @"'Incident Number' = """ + idIncidente + @"""";
            remedyWS.GetListOutputMapGetListValues[] dsresult;

            dsresult = obj.HelpDesk_GetList(Classification, "0", "1");

            Chamado chamado = new Chamado();
            foreach (remedyWS.GetListOutputMapGetListValues item in dsresult)
            {
                chamado.Area_Designada = item.Assigned_Group;
                chamado.Data_Abertura = Convert.ToDateTime(item.Submit_Date);
                chamado.Descricao = item.Description;
                chamado.Detalhe = item.Detailed_Decription;
                chamado.DtAtualizacao = DateTime.Now;
                if (!String.IsNullOrEmpty(item.Last_Resolved_Date))
                {
                    chamado.DtFechamento = Convert.ToDateTime(item.Last_Resolved_Date);
                }

                chamado.DtUltimaInteracao = Convert.ToDateTime(item.Last_Modified_Date);
                chamado.Empresa = item.Company;
                chamado.IdIncidente = item.Incident_Number;
                chamado.Prioridade = item.Priority.ToString();
                chamado.Resolucao = item.Resolution;
                chamado.Status = item.Status.ToString();
                chamado.Pessoa_Designada = item.Assignee;
                chamado.CausaIncidente = item.Generic_Categorization_Tier_1;
            }

            return chamado;
        }

        public bool x(Chamado chamado, byte[] arquivo, string nomedoarquivo, int tamanhoarquivo)
        {
            bool inserted = false;


            remedyWS.ITPAM_HPD_HelpDesk_WSService obj = new remedyWS.ITPAM_HPD_HelpDesk_WSService();
            remedyWS.AuthenticationInfo AuthenticationInfoValue = new remedyWS.AuthenticationInfo();

            AuthenticationInfoValue.userName = remedyUserName;
            AuthenticationInfoValue.password = Tools.Decrypt(remedyPassword, true);
            obj.AuthenticationInfoValue = AuthenticationInfoValue;
            obj.Timeout = 999999999;

            System.Net.WebProxy proxy = new System.Net.WebProxy(proxyServer, 80);
            System.Net.NetworkCredential cred = new System.Net.NetworkCredential();
            cred.Domain = "corporate";
            cred.UserName = AuthenticationInfoValue.userName;
            cred.Password = AuthenticationInfoValue.password;
            proxy.Credentials = cred;
            obj.Proxy = proxy;
            string Categorizacao1 = string.Empty;
            string Categorizacao2 = string.Empty;
            string Categorizacao3 = string.Empty;

            string AcceleratorItem1 = string.Empty;
            string AcceleratorItem2 = string.Empty;
            string AcceleratorItem3 = string.Empty;
            string AcceleratorItem4 = string.Empty;
            string AcceleratorItem5 = string.Empty;
            string Acknowledgment_Start_Date = string.Empty;
            bool Acknowledgment_Start_DateSpecified = false;
            string Additional_Location_Details = string.Empty;
            string Area_Code = string.Empty;
            string Assigned_Group = "DO-DSE-SUPORTE NÍVEL 1";
            string Assigned_Group_ID = "SGP000000001563";
            string Assigned_Group_Shift_ID = string.Empty; ;
            string Assigned_Group_Shift_Name = string.Empty; ;

            remedyWS.Assigned_Group_Uses_OLAType Assigned_Group_Uses_OLA;
            Assigned_Group_Uses_OLA = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.Yes;
            bool Assigned_Group_Uses_OLASpecified = true;

            string Assigned_Support_Company = "BOVESPA - BOLSA DE S.PAULO";
            string Assigned_Support_Organization = "TI";
            string Assignee = string.Empty;
            string Assignee_Groups = string.Empty;
            string Assignee_Id = string.Empty;
            string Assignee_Login_ID = string.Empty;
            string Assignee_Select_Form = string.Empty;

            remedyWS.Assignment_MethodType Assignment_Method = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assignment_MethodType.SystemAssigned;
            bool Assignment_MethodSpecified = false;

            remedyWS.Assignment_AcceleratorType Assignment_Accelerator = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assignment_AcceleratorType.AutoAssign;
            bool Assignment_AcceleratorSpecified = false;

            string Association_Description = string.Empty;
            string Attachment_attachmentName = string.Empty;
            byte[] Attachment_attachmentData = null;
            int Attachment_attachmentOrigSize = 0;
            bool Attachment_attachmentOrigSizeSpecified = false;
            string BiiARS_01 = string.Empty;
            string BiiARS_02 = string.Empty;
            string BiiARS_03 = string.Empty;
            string BiiARS_04 = string.Empty;
            string BiiARS_05 = string.Empty;
            string bOrphanedRoot = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType Broadcasted_Flag = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool Broadcasted_FlagSpecified = false;
            decimal Budget_Cost__Currency_currencyValue = 0;
            bool Budget_Cost__Currency_currencyValueSpecified = false;
            string Budget_Cost__Currency_currencyCode = string.Empty;
            string Budget_Cost__Currency_currencyConversionDate = string.Empty;
            bool Budget_Cost__Currency_currencyConversionDateSpecified = false;


            string Categorization_Tier_1 = string.Empty;
            string Categorization_Tier_2 = string.Empty;
            string Categorization_Tier_3 = string.Empty;

            if (chamado.TipoChamado == "Duvida")
            {
                Categorization_Tier_1 = "Suporte";
                Categorization_Tier_2 = "Dúvidas Sinacor";
            }
            else
            {
                Categorization_Tier_1 = "Incidente Producao";
                Categorization_Tier_2 = "Integridade";
            }

            string cell_name = string.Empty;
            remedyWS.Change_in_SequenceType Change_in_Sequence = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Change_in_SequenceType.Yes;
            bool Change_in_SequenceSpecified = false;
            string CI_Tag_Number = string.Empty;
            string City = string.Empty;
            string Closed_Date = string.Empty;
            bool Closed_DateSpecified = false;
            string Closure_Manufacturer = string.Empty;
            string Closure_Product_Category_Tier1 = string.Empty;
            string Closure_Product_Category_Tier2 = string.Empty;
            string Closure_Product_Category_Tier3 = string.Empty;
            string Closure_Product_Model_Version = string.Empty;
            string Closure_Product_Name = string.Empty;
            remedyWS.Closure_SourceType Closure_Source = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Closure_SourceType.Blank;
            bool Closure_SourceSpecified = false;
            string Command = string.Empty;
            string Company = chamado.Empresa;
            string Component_ID = string.Empty;
            string ConditionDisplay1 = string.Empty;
            string ConditionDisplay2 = string.Empty;
            string ConditionDisplay3 = string.Empty;
            string ConditionDisplay4 = string.Empty;
            string ConditionDisplay5 = string.Empty;
            remedyWS.Contact_Client_TypeType Contact_Client_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Contact_Client_TypeType.Customer;
            bool Contact_Client_TypeSpecified = false;
            string Contact_Company = chamado.Empresa;
            remedyWS.Contact_SensitivityType Contact_Sensitivity = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Contact_SensitivityType.Standard;
            bool Contact_SensitivitySpecified = false;
            string Corporate_ID = string.Empty;
            string Cost_Center = string.Empty;
            string Country = string.Empty;
            string Country_Code = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType Created_from_Template = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool Created_from_TemplateSpecified = true;
            string Created_By = "p-mbastos";
            remedyWS.Created_From_flagType Created_From_flag = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Created_From_flagType.Incident;
            bool Created_From_flagSpecified = false;
            string CurrentStage = string.Empty;
            int CurrentStageNumber = 2;
            bool CurrentStageNumberSpecified = false;
            string DataTags = string.Empty;
            string Department = string.Empty;
            string Description = chamado.Descricao;
            string Desk_Location = string.Empty;
            string Detailed_Decription = chamado.Detalhe;
            string Direct_Contact_Area_Code = string.Empty;
            string Direct_Contact_City = string.Empty;
            string Direct_Contact_Company = chamado.Empresa;
            string Direct_Contact_Country = "Brazil";
            string Direct_Contact_Country_Code = string.Empty;
            string Direct_Contact_Department = string.Empty;
            string Direct_Contact_Desk_Location = string.Empty;
            string Direct_Contact_Extension = string.Empty;
            string Direct_Contact_First_Name = chamado.Contato;
            string Direct_Contact_Internet_Email = chamado.Email;
            string Direct_Contact_Last_Name = string.Empty;
            string Direct_Contact_Local_Number = string.Empty;
            string Direct_Contact_Location_Details = string.Empty;
            string Direct_Contact_Mail_Station = string.Empty;
            string Direct_Contact_Middle_Initial = string.Empty;
            string Direct_Contact_Organization = string.Empty;
            string Direct_Contact_Person_ID = string.Empty;
            string Direct_Contact_Phone_Number = chamado.Telefone;
            string Direct_Contact_Region = string.Empty;
            string Direct_Contact_Site = string.Empty;
            string Direct_Contact_Site_Group = string.Empty;
            string Direct_Contact_Site_ID = string.Empty;
            string Direct_Contact_State_Province = string.Empty;
            string Direct_Contact_Street = string.Empty;
            string Direct_Contact_Time_Zone = string.Empty;
            string Direct_Contact_Zip_Postal_Code = string.Empty;
            int DR = 0;
            bool DRSpecified = false;
            int Effort_Time_Spent_Minutes = 0;
            bool Effort_Time_Spent_MinutesSpecified = false;
            int EH = 0;
            bool EHSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType Enable_Assignment_Engine = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool Enable_Assignment_EngineSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType Enable_CI_Related_lookup = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool Enable_CI_Related_lookupSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType Enable_CI_Warranty_Lookup = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool Enable_CI_Warranty_LookupSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType Escalated = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool EscalatedSpecified = false;
            string Estimated_Resolution_Date = string.Empty;
            bool Estimated_Resolution_DateSpecified = false;
            string Extension = string.Empty;
            string First_Name = chamado.PrimeiroNome ;
            string first_name2 = string.Empty;

            remedyWS.Assigned_Group_Uses_OLAType Flag_Create_Request = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.Yes;
            bool Flag_Create_RequestSpecified = true;

            string Generic_Categorization_Tier_1 = string.Empty;
            string Generic_Categorization_Tier_2 = string.Empty;
            string Generic_Categorization_Tier_3 = string.Empty;
            string GEOnet = string.Empty;
            string Global_OR_Custom_Mapping = string.Empty;
            int Group_Transfers = 0;
            bool Group_TransfersSpecified = false;
            string HR_ID = string.Empty;

            //1000000163
            remedyWS.ImpactType Impact = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.ImpactType.Item1ExtensiveWidespread;
            bool ImpactSpecified = true;

            string Impact_OR_Root = string.Empty;
            int Inbound = 0;
            bool InboundSpecified = false;
            remedyWS.Incident_Association_TypeType Incident_Association_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Incident_Association_TypeType.Original;
            bool Incident_Association_TypeSpecified = false;
            string Incident_Location = string.Empty;
            string Incident_Number = "INC000000000001";
            int Individual_Transfers = 0;
            bool Individual_TransfersSpecified = false;
            string InstanceId = string.Empty;
            string Internet_Email = string.Empty;
            string Last__Assigned_Date = string.Empty;
            string Last_Acknowledged_Date = string.Empty;
            bool Last_Acknowledged_DateSpecified = false;
            string Last_Date_Duration_Calculated = string.Empty;
            bool Last_Date_Duration_CalculatedSpecified = false;
            string Last_Name = " ";
            string Last_Resolved_Date = string.Empty;
            bool Last_Resolved_DateSpecified = false;
            string Last_SLA_Hold_Date = string.Empty;
            bool Last_SLA_Hold_DateSpecified = false;
            string last_name2 = string.Empty;
            string Local_Phone = chamado.Telefone;
            string Login_ID = string.Empty;
            string LookupKeyword = string.Empty;
            string Mail_Station = string.Empty;
            string Manufacturer = string.Empty;
            string mc_ueid = string.Empty;
            string Middle_Initial = string.Empty;
            string Mode = string.Empty;
            string Next_Target_Date = string.Empty;
            bool Next_Target_DateSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType OLA_Hold = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool OLA_HoldSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType Onwer_Group_Uses_SLA = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool Onwer_Group_Uses_SLASpecified = false;
            string OptionForClosingIncident = string.Empty;
            string Organization = string.Empty;
            string Original_Incident_Number = string.Empty;
            string Original_Last_Modified_By = string.Empty;
            string Original_Last_Modified_Date = string.Empty;
            bool Original_Last_Modified_DateSpecified = false;
            int Outbound = 0;
            bool OutboundSpecified = false;
            string Owner = string.Empty;
            string Owner_Group = string.Empty;
            string Owner_Group_ID = string.Empty;
            string Owner_Login_ID = string.Empty;
            string Owner_Support_Company = "BOVESPA - BOLSA DE S.PAULO";
            string Owner_Support_Organization = "TI";
            string Person_ID = string.Empty;
            string Phone_Number = chamado.Telefone;
            string policy_name = string.Empty;
            string PreviousStatus = string.Empty;

            //1000000164
            remedyWS.PriorityType Priority = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.PriorityType.Critical;
            bool PrioritySpecified = true;

            int Priority_Weight = 0;
            bool Priority_WeightSpecified = false;
            string Product_Categorization_Tier_1 = "Software";
            string Product_Categorization_Tier_2 = "Aplicativo de Apoio";
            string Product_Categorization_Tier_3 = "Outros";
            string Product_Model_Version = "";
            string Product_Name = string.Empty;
            string ReOpened_Date = string.Empty;
            bool ReOpened_DateSpecified = false;
            string Reason_Code = string.Empty;
            string Reason_Description = string.Empty;
            remedyWS.Record_TypeType Record_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Record_TypeType.Blank;
            bool Record_TypeSpecified = false;
            string Region = string.Empty;
            string Reported_Date = string.Empty;
            bool Reported_DateSpecified = false;
            remedyWS.Reported_SourceType Reported_Source = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Reported_SourceType.Web;
            bool Reported_SourceSpecified = false;
            string Reported_to_Vendor = "";
            bool Reported_to_VendorSpecified = false;
            string Required_Resolution_DateTime = string.Empty;
            bool Required_Resolution_DateTimeSpecified = false;
            string Resolution = "";
            string Resolution_Category = "";
            string Resolution_Category_Tier_2 = "";
            string Resolution_Category_Tier_3 = "";
            string Resolution_Method = "";
            string Resolution_Start_Date = "";
            bool Resolution_Start_DateSpecified = false;
            string Responded_Date = "";
            bool Responded_DateSpecified = false;
            string Return_Code = string.Empty;
            string root_component_id_list = string.Empty;
            string root_incident_id_list = string.Empty;
            string Satisfaction_Rating = "";
            string Search_Bar = string.Empty;
            remedyWS.Service_Entitlement_MethodType Service_Entitlement_Method = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Service_Entitlement_MethodType.None;
            bool Service_Entitlement_MethodSpecified = false;

            //1000000099
            remedyWS.Service_TypeType Service_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Service_TypeType.UserServiceRestoration;
            bool Service_TypeSpecified = true;

            remedyWS.Assigned_Group_Uses_OLAType Shifts_Flag = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool Shifts_FlagSpecified = false;
            string Short_Description = chamado.Descricao;
            string Show_For_Process = string.Empty;
            string Site = string.Empty;
            string Site_Group = string.Empty;
            string Site_ID = string.Empty;
            string SLA_Breach_Exception = string.Empty;
            string SLA_Breach_Reason = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType SLA_Hold = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool SLA_HoldSpecified = false;
            int SLA_Res_Business_Hour_Seconds = 0;
            bool SLA_Res_Business_Hour_SecondsSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType SLA_Responded = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool SLA_RespondedSpecified = false;
            remedyWS.PriorityType SLM_Priority = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.PriorityType.Critical;
            bool SLM_PrioritySpecified = false;
            remedyWS.SLM_StatusType SLM_Status = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.SLM_StatusType.NoServiceTargetAssigned;
            bool SLM_StatusSpecified = false;
            string SLMEventLookupTblKeyword = string.Empty;
            string SLMLookupTblKeyword = string.Empty;
            string SRAttachment_attachmentName = string.Empty;
            byte[] SRAttachment_attachmentData = null;
            int SRAttachment_attachmentOrigSize = 0;
            bool SRAttachment_attachmentOrigSizeSpecified = false;
            string SRID = string.Empty;
            string SRInstanceID = string.Empty;
            string SRMS_Registry_Instance_ID = string.Empty;
            string SRMSAOIGuid = string.Empty;
            string StageCondition = string.Empty;
            string State_Province = string.Empty;
            remedyWS.StatusType Status = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.StatusType.New;
            bool StatusSpecified = false;
            remedyWS.StatusPPLType StatusPPL = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.StatusPPLType.Enabled;
            bool StatusPPLSpecified = false;
            string status_incident = string.Empty;
            remedyWS.Status_ReasonType Status_Reason = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Status_ReasonType.Blank;
            bool Status_ReasonSpecified = false;
            string status_reason2 = string.Empty;
            string Street = string.Empty;
            string Submitter = "p-mbastos";
            string TemplateID = string.Empty;
            remedyWS.TicketTypeType TicketType = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.TicketTypeType.Incident;
            bool TicketTypeSpecified = false;
            string Time_Zone = string.Empty;
            decimal Total_Cost__Currency_currencyValue = 0;
            bool Total_Cost__Currency_currencyValueSpecified = false;
            string Total_Cost__Currency_currencyCode = string.Empty;
            string Total_Cost__Currency_currencyConversionDate = string.Empty;
            bool Total_Cost__Currency_currencyConversionDateSpecified = false;
            int Total_Escalation_Level = 0;
            bool Total_Escalation_LevelSpecified = false;
            int Total_OLA_AcknowledgeEsc_Level = 0;
            bool Total_OLA_AcknowledgeEsc_LevelSpecified = false;
            int Total_OLA_Resolution_Esc_Level = 0;
            bool Total_OLA_Resolution_Esc_LevelSpecified = false;
            int Total_Time_Spent = 0;
            bool Total_Time_SpentSpecified = false;
            int Total_Transfers = 0;
            bool Total_TransfersSpecified = false;
            remedyWS.UnknownUserType UnknownUser = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.UnknownUserType.False;
            bool UnknownUserSpecified = false;

            //1000000162
            remedyWS.UrgencyType Urgency = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.UrgencyType.Item1Critical;
            bool UrgencySpecified = true;

            string use_case = string.Empty;
            remedyWS.Vendor_Assignment_StatusType Vendor_Assignment_Status = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Vendor_Assignment_StatusType.Assigned;
            bool Vendor_Assignment_StatusSpecified = false;
            string Vendor_Email = string.Empty;
            string Vendor_First_Name = string.Empty;
            string Vendor_Group = string.Empty;
            string Vendor_Group_ID = string.Empty;
            string Vendor_Last_Name = string.Empty;
            string Vendor_Login_ID = string.Empty;
            string Vendor_Name = string.Empty;
            string Vendor_Organization = string.Empty;
            string Vendor_Person_ID = string.Empty;
            string Vendor_Phone = string.Empty;
            string Vendor_Resolved_Date = string.Empty;
            bool Vendor_Resolved_DateSpecified = false;
            string Vendor_Responded_On = string.Empty;
            bool Vendor_Responded_OnSpecified = false;
            string Vendor_Ticket_Number = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType VIP = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.Yes;
            bool VIPSpecified = true;
            string Web_Incident_ID = string.Empty;
            string z1D_ACD_Phone_Number = string.Empty;
            string z1D_Action = string.Empty;
            string z1D_Action03 = string.Empty;
            remedyWS.z1D_Assign_To_Current_UserType z1D_Assign_To_Current_User = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Assign_To_Current_UserType.No;
            bool z1D_Assign_To_Current_UserSpecified = false;
            string z1D_Assigned_Group_Role = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Assigned_Group_Uses_SLA = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_Assigned_Group_Uses_SLASpecified = false;
            remedyWS.Change_in_SequenceType z1D_Assignment_Change = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Change_in_SequenceType.Yes;
            bool z1D_Assignment_ChangeSpecified = false;
            string z1D_Assoc_Action_Assc_Type01V = string.Empty;
            string z1D_Assoc_Action_Form01V = string.Empty;
            string z1D_Assoc_Description_Modified = string.Empty;
            remedyWS.StatusPPLType z1D_Assoc_Status = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.StatusPPLType.Enabled;
            bool z1D_Assoc_StatusSpecified = false;
            string z1D_Associated_CI_Related_Act = string.Empty;
            remedyWS.StatusType z1D_Associated_Incident_Status = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.StatusType.New;
            bool z1D_Associated_Incident_StatusSpecified = false;
            string z1D_Association_Action01 = string.Empty;
            string z1D_Association_Action01_locale = string.Empty;
            string z1D_Association_End_Date = string.Empty;
            bool z1D_Association_End_DateSpecified = false;
            string z1D_Association_Start_Date = string.Empty;
            bool z1D_Association_Start_DateSpecified = false;
            remedyWS.z1D_Association_Type01Type z1D_Association_Type01 = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Association_Type01Type.Created;
            bool z1D_Association_Type01Specified = false;
            string z1D_Audit_Priority = string.Empty;
            string z1D_Audit_Service_Type = string.Empty;
            int z1D_Audit_TransactionGroupNum = 0;
            bool z1D_Audit_TransactionGroupNumSpecified = false;
            int z1D_Audit_TransactionGroupNum1 = 0;
            bool z1D_Audit_TransactionGroupNum1Specified = false;
            string z1D_Automatically_Associate_Customer_CI = string.Empty;
            string z1D_Broadcast_Action = string.Empty;
            string z1D_Broadcast_Number = string.Empty;
            remedyWS.z1D_Calculate_SLM_DurationsType z1D_Calculate_SLM_Durations = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Calculate_SLM_DurationsType.CalculateSLMDurations;
            bool z1D_Calculate_SLM_DurationsSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Changeable_Reported_Date = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.Yes;
            bool z1D_Changeable_Reported_DateSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Changeable_Resolved_Date = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.Yes;
            bool z1D_Changeable_Resolved_DateSpecified = true;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Changeable_Responded_Date = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.Yes;
            bool z1D_Changeable_Responded_DateSpecified = true;
            string z1D_Char01 = string.Empty;
            string z1D_Char01NoChangeFlagV = string.Empty;
            string z1D_Char02 = string.Empty;
            string z1D_Char03 = string.Empty;
            string z1D_Char04 = string.Empty;
            string z1D_Char05 = string.Empty;
            string z1D_Char06 = string.Empty;
            string z1D_Char07 = string.Empty;
            string z1D_Char08 = string.Empty;
            string z1D_Char09 = string.Empty;
            string z1D_Char10 = string.Empty;
            string z1D_Char11 = string.Empty;
            string z1D_Char12 = string.Empty;
            string z1D_Char13 = string.Empty;
            string z1D_Char14 = string.Empty;
            string z1D_Char15 = string.Empty;
            string z1D_Char16 = string.Empty;
            string z1D_Char17 = string.Empty;
            string z1D_Char18 = string.Empty;
            string z1D_Char19 = string.Empty;
            string z1D_Char20 = string.Empty;
            string z1D_Char21 = string.Empty;
            string z1D_Char22 = string.Empty;
            string z1D_Char23 = string.Empty;
            string z1D_Char24 = string.Empty;
            string z1D_Char25 = string.Empty;
            string z1D_Char26 = string.Empty;
            string z1D_Char27 = string.Empty;
            string z1D_Char28 = string.Empty;
            string z1D_Char29 = string.Empty;
            string z1D_Char30 = string.Empty;
            string z1D_Char31 = string.Empty;
            string z1D_CI_Name = string.Empty;
            string z1D_CI_Number = string.Empty;
            string z1D_Configuration_Item_ID = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Copied_To_New_Flag = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_Copied_To_New_FlagSpecified = false;
            string z1D_Date01 = string.Empty;
            bool z1D_Date01Specified = false;
            string z1D_Date02 = string.Empty;
            bool z1D_Date02Specified = false;
            string z1D_Date03 = string.Empty;
            bool z1D_Date03Specified = false;
            string z1D_Date04 = string.Empty;
            bool z1D_Date04Specified = false;
            string z1D_Date05 = string.Empty;
            bool z1D_Date05Specified = false;
            string z1D_Date06 = string.Empty;
            bool z1D_Date06Specified = false;
            string z1D_Default_Support_Group_ID = string.Empty;
            string z1D_Dialog_Action = string.Empty;
            int z1D_Effort_Time_Hold_Duration = 0;
            bool z1D_Effort_Time_Hold_DurationSpecified = false;
            string z1D_Entry_Exists = string.Empty;
            string z1D_Estimated_Resolution_Date = string.Empty;
            bool z1D_Estimated_Resolution_DateSpecified = false;
            string z1D_Functional_Role = string.Empty;
            string z1D_Generated_Entry_ID_ID = string.Empty;
            string z1D_Hold_Status = string.Empty;
            string z1D_HPD_Template_ID = string.Empty;
            remedyWS.z1D_Association_Type01Type z1D_Incident_CI_Association_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Association_Type01Type.Created;
            bool z1D_Incident_CI_Association_TypeSpecified = false;
            string z1D_Incident_Number = string.Empty;
            string z1D_Infrastructure_Change_ID = string.Empty;
            int z1D_Integer01 = 0;
            bool z1D_Integer01Specified = false;
            int z1D_Integer02 = 0;
            bool z1D_Integer02Specified = false;
            int z1D_Integer03 = 0;
            bool z1D_Integer03Specified = false;
            int z1D_Integer04 = 0;
            bool z1D_Integer04Specified = false;
            int z1D_Integer05 = 0;
            bool z1D_Integer05Specified = false;
            int z1D_Integer06 = 0;
            bool z1D_Integer06Specified = false;
            remedyWS.z1D_Just_Made_DuplicateType z1D_Just_Made_Duplicate = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Just_Made_DuplicateType.YesFromDuplicateIncident;
            bool z1D_Just_Made_DuplicateSpecified = false;
            string z1D_Known_Error_ID = string.Empty;
            int z1D_Last_Modified_DateInteger = 0;
            bool z1D_Last_Modified_DateIntegerSpecified = false;
            int z1D_Lastcount = 0;
            bool z1D_LastcountSpecified = false;
            int z1D_Lastcount02 = 0;
            bool z1D_Lastcount02Specified = false;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Lock_Down_Dialog = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_Lock_Down_DialogSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Lock_Down_Dialog02 = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_Lock_Down_Dialog02Specified = false;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Lock_Down_Impact_Dialog = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_Lock_Down_Impact_DialogSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Locked_Down = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_Locked_DownSpecified = false;
            int z1D_Max_Weight = 0;
            bool z1D_Max_WeightSpecified = false;
            string z1D_Message_Tag = string.Empty;
            string z1D_Mobile_Worklog_Upd = string.Empty;
            string z1D_Mode = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Modify_All_FlagV = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_Modify_All_FlagVSpecified = false;
            string z1D_New_Description = string.Empty;
            string z1D_Notification_Message_Tag = string.Empty;
            remedyWS.z1D_Notification_TypeType z1D_Notification_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Notification_TypeType.External;
            bool z1D_Notification_TypeSpecified = false;
            string z1D_NT_Functional_Role = string.Empty;
            string z1D_NT_Internet_Email = string.Empty;
            string z1D_NT_On_Call_Group_Flag = string.Empty;
            string z1D_NT_Pager_Message_Numeric = string.Empty;
            string z1D_NT_Remedy_Login_ID = string.Empty;
            string z1D_NT_Support_Group_ID = string.Empty;
            string z1D_NT_Support_Group_Shift_ID = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType z1D_On_Call_Group_Flag = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_On_Call_Group_FlagSpecified = false;
            string z1D_Original_Description = string.Empty;
            remedyWS.Incident_Association_TypeType z1D_Original_Incident_IAT = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Incident_Association_TypeType.Original;
            bool z1D_Original_Incident_IATSpecified = false;
            string z1D_Original_Incident_OIN = string.Empty;
            string z1D_Original_Incident_Rpt_Date = string.Empty;
            bool z1D_Original_Incident_Rpt_DateSpecified = false;
            remedyWS.StatusType z1D_Original_StatusINC = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.StatusType.New;
            bool z1D_Original_StatusINCSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Owner_Group_Shifts_Flag = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_Owner_Group_Shifts_FlagSpecified = false;
            string z1D_Parent_ID = string.Empty;
            int z1D_Permission_Group_ID = 0;
            bool z1D_Permission_Group_IDSpecified = false;
            string z1D_Permission_Group_List = string.Empty;
            int z1D_Prev_Assignee_Effort_Hold = 0;
            bool z1D_Prev_Assignee_Effort_HoldSpecified = false;
            int z1D_Prev_Assignee_Effort_Spent = 0;
            bool z1D_Prev_Assignee_Effort_SpentSpecified = false;
            string z1D_Prev_Assignee_Group_ID = string.Empty;
            string z1D_Prev_Assignee_Login_ID = string.Empty;
            int z1D_Prev_Assignee_Total_Effort = 0;
            bool z1D_Prev_Assignee_Total_EffortSpecified = false;
            remedyWS.Incident_Association_TypeType z1D_Prev_Incident_Assoc_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Incident_Association_TypeType.Original;
            bool z1D_Prev_Incident_Assoc_TypeSpecified = false;
            string z1D_Prev_Owner_Group_ID = string.Empty;
            string z1D_Prev_Reported_to_Vendor = string.Empty;
            bool z1D_Prev_Reported_to_VendorSpecified = false;
            remedyWS.StatusType z1D_Prev_StatusINC = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.StatusType.New;
            bool z1D_Prev_StatusINCSpecified = false;
            string z1D_Prev_Status_Reason = string.Empty;
            string z1D_Prev_Vendor_Group_ID = string.Empty;
            string z1D_Prev_Vendor_Resolved_Date = string.Empty;
            bool z1D_Prev_Vendor_Resolved_DateSpecified = false;
            string z1D_Prev_Vendor_Responded_On = string.Empty;
            bool z1D_Prev_Vendor_Responded_OnSpecified = false;
            string z1D_Previous_Operation = string.Empty;
            string z1D_Previous_Reported_Date = string.Empty;
            bool z1D_Previous_Reported_DateSpecified = false;
            string z1D_Previous_Resolved_Date = string.Empty;
            bool z1D_Previous_Resolved_DateSpecified = false;
            string z1D_Previous_Responded_Date = string.Empty;
            bool z1D_Previous_Responded_DateSpecified = false;
            string z1D_Problem_Investigation_ID = string.Empty;
            string z1D_ReOpened_Incident_Number = string.Empty;
            string z1D_Report_Form_Name = string.Empty;
            string z1D_Report_Form_View = string.Empty;
            string z1D_Report_Locale = string.Empty;
            string z1D_Report_Name = string.Empty;
            string z1D_Report_Qualification = string.Empty;
            string z1D_Report_Target = string.Empty;
            string z1D_Reported_Date = string.Empty;
            bool z1D_Reported_DateSpecified = false;
            string z1D_Request_Number = string.Empty;
            string z1D_Request_Type01 = string.Empty;
            string z1D_Request02 = string.Empty;
            string z1D_Required_Resolution_Date = string.Empty;
            bool z1D_Required_Resolution_DateSpecified = false;
            string z1D_Run_Process_Password = string.Empty;
            string z1D_Run_Process_Setup = string.Empty;
            string z1D_Selected_Template_ID = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Service_Entitlement = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_Service_EntitlementSpecified = false;
            string z1D_Solution_Database_ID = string.Empty;
            remedyWS.StatusType z1D_Status = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.StatusType.New;
            bool z1D_StatusSpecified = false;
            remedyWS.StatusType z1D_StatusINC = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.StatusType.New;
            bool z1D_StatusINCSpecified = false;
            int z1D_Status_Integer_Parm01 = 0;
            bool z1D_Status_Integer_Parm01Specified = false;
            int z1D_Status_Integer_Parm02 = 0;
            bool z1D_Status_Integer_Parm02Specified = false;
            string z1D_System_Role = string.Empty;
            remedyWS.z1D_Association_Type01Type z1D_Table_Association_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Association_Type01Type.Created;
            bool z1D_Table_Association_TypeSpecified = false;
            string z1D_Table_Request_ID = string.Empty;
            remedyWS.Record_TypeType z1D_Table_Request_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Record_TypeType.Blank;
            bool z1D_Table_Request_TypeSpecified = false;
            string z1D_TableChar01 = string.Empty;
            string z1D_TableChar02 = string.Empty;
            string z1D_TableChar03 = string.Empty;
            remedyWS.z1D_Association_Type01Type z1D_Template_CI_Relation_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Association_Type01Type.Created;
            bool z1D_Template_CI_Relation_TypeSpecified = false;
            string z1D_Template_Related_CI = string.Empty;
            string z1D_TempLocaleV = string.Empty;
            string z1D_Ticket_Effort_Start_Time = string.Empty;
            bool z1D_Ticket_Effort_Start_TimeSpecified = false;
            string z1D_Ticket_Start_Time = string.Empty;
            bool z1D_Ticket_Start_TimeSpecified = false;
            int z1D_TmpDays = 0;
            bool z1D_TmpDaysSpecified = false;
            int z1D_TmpHours = 0;
            bool z1D_TmpHoursSpecified = false;
            int z1D_TmpMinutes = 0;
            bool z1D_TmpMinutesSpecified = false;
            int z1D_Total_Incidents_Count = 0;
            bool z1D_Total_Incidents_CountSpecified = false;
            string z1D_Update_Associated_Incident = string.Empty;
            string z1D_Vendor_Group_ID = string.Empty;
            string z1D_Window_Action = string.Empty;
            string z1D_WorkLog_Assigned_Group = string.Empty;
            string z1D_WorkLog_Assignee = string.Empty;
            string z1D_AccerleratorAction = string.Empty;
            remedyWS.z1D_Activity_TypeType z1D_Activity_Type = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Activity_TypeType.WorkingLog;
            bool z1D_Activity_TypeSpecified = false;
            string z1D_ActivityDate_tab = string.Empty;
            bool z1D_ActivityDate_tabSpecified = false;
            string z1D_AssigneeManager = string.Empty;
            string z1D_AssigneeManagerLogin = string.Empty;
            string z1D_AssociationFormName = string.Empty;
            remedyWS.z1D_Association_Type01Type z1D_AssociationType02 = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Association_Type01Type.Created;
            bool z1D_AssociationType02Specified = false;
            string z1D_CI_InstanceID = string.Empty;
            string z1D_CI_Related_DateSetID = string.Empty;
            string z1D_ClassName = string.Empty;
            remedyWS.z1D_CommunicationSourceType z1D_CommunicationSource = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_CommunicationSourceType.Web;
            bool z1D_CommunicationSourceSpecified = false;
            string z1D_ContactCIAssocTblKeyword = string.Empty;
            string z1D_Cost_Category = string.Empty;
            string z1D_Cost_Type = string.Empty;
            remedyWS.StatusType z1D_CurrentDatabaseStatus = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.StatusType.New;
            bool z1D_CurrentDatabaseStatusSpecified = false;
            string z1D_DataSetName = string.Empty;
            remedyWS.Change_in_SequenceType z1D_DefaultCompanyAction = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Change_in_SequenceType.Yes;
            bool z1D_DefaultCompanyActionSpecified = false;
            int z1D_DefaultCompanyInteger = 0;
            bool z1D_DefaultCompanyIntegerSpecified = false;
            string z1D_Details = string.Empty;
            string z1D_DisplayStatusReason = string.Empty;
            string z1D_HelpText = string.Empty;
            int z1D_Integer = 0;
            bool z1D_IntegerSpecified = false;
            string z1D_Local_DataSetID = string.Empty;
            string z1D_Namespace = string.Empty;
            remedyWS.z1D_NotifyIndGrpType z1D_NotifyIndGrp = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_NotifyIndGrpType.Individual;
            bool z1D_NotifyIndGrpSpecified = false;
            int z1D_NumberOfApproval = 0;
            bool z1D_NumberOfApprovalSpecified = false;
            remedyWS.z1D_Association_Type01Type z1D_OppositeAssociation = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Association_Type01Type.Created;
            bool z1D_OppositeAssociationSpecified = false;
            string z1D_OutageTblKeyword = string.Empty;
            string z1D_ParentInstanceId = string.Empty;
            string z1D_PrefixHolder = string.Empty;
            string z1D_PrefixResult = string.Empty;
            string z1D_Previous_Assignee_Login_ID = string.Empty;
            int z1D_PreviousStageNumber = 0;
            bool z1D_PreviousStageNumberSpecified = false;
            string z1D_Process_Id = string.Empty;
            string z1D_ProcessFlowAction = string.Empty;
            string z1D_ProcessFlowContactAction = string.Empty;
            remedyWS.Change_in_SequenceType z1D_Reassign = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Change_in_SequenceType.Yes;
            bool z1D_ReassignSpecified = false;
            string z1D_RecordType_Char = string.Empty;
            string z1D_RefreshContactTab = string.Empty;
            string z1D_RefreshFinancialsTab = string.Empty;
            string z1D_RefreshRelatedAssetsTab = string.Empty;
            string z1D_RefreshRelationshipsTab = string.Empty;
            string z1D_RefreshSLMTab = string.Empty;
            string z1D_RefreshTasksTab = string.Empty;
            string z1D_RefreshWITab = string.Empty;
            string z1D_RelationAction = string.Empty;
            remedyWS.Record_TypeType z1D_RequestTypeTblValue = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Record_TypeType.Blank;
            bool z1D_RequestTypeTblValueSpecified = false;
            string z1D_schemaID = string.Empty;
            string z1D_SchemaName = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType z1D_Secure_Log = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1D_Secure_LogSpecified = false;
            string z1D_Status_Reason = string.Empty;
            string z1D_Summary = string.Empty;
            int z1D_Task_Event_Code = 0;
            bool z1D_Task_Event_CodeSpecified = false;
            string z1D_Task_Event_Info_1 = string.Empty;
            string z1D_Task_Event_Info_2 = string.Empty;
            string z1D_Task_Event_Info_3 = string.Empty;
            string z1D_Task_Event_Info_4 = string.Empty;
            string z1D_Task_Event_Info_5 = string.Empty;
            string z1D_Task_Event_Info_6 = string.Empty;
            string z1D_Task_Id = string.Empty;
            string z1D_Task_instance_Id = string.Empty;
            remedyWS.z1D_Task_or_Task_GroupType z1D_Task_or_Task_Group = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_Task_or_Task_GroupType.Task;
            bool z1D_Task_or_Task_GroupSpecified = false;
            remedyWS.Change_in_SequenceType z1D_Task_Read_Only = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Change_in_SequenceType.Yes;
            bool z1D_Task_Read_OnlySpecified = false;
            string z1D_TaskSubtype = string.Empty;
            remedyWS.z1D_TaskTypeType z1D_TaskType = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_TaskTypeType.Manual;
            bool z1D_TaskTypeSpecified = false;
            decimal z1D_TCOCost_currencyValue = 0;
            bool z1D_TCOCost_currencyValueSpecified = false;
            string z1D_TCOCost_currencyCode = string.Empty;
            string z1D_TCOCost_currencyConversionDate = string.Empty;
            bool z1D_TCOCost_currencyConversionDateSpecified = false;
            remedyWS.Change_in_SequenceType z1D_Triggered_Assignment = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Change_in_SequenceType.Yes;
            bool z1D_Triggered_AssignmentSpecified = false;
            remedyWS.z1D_TypeSelectorType z1D_TypeSelector = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_TypeSelectorType.Adhoc;
            bool z1D_TypeSelectorSpecified = false;
            remedyWS.z1D_View_AccessType z1D_View_Access = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1D_View_AccessType.Public;
            bool z1D_View_AccessSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType z1DRefresh = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1DRefreshSpecified = false;
            remedyWS.Change_in_SequenceType z1G_Disable_Service_Entitlment = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Change_in_SequenceType.Yes;
            bool z1G_Disable_Service_EntitlmentSpecified = false;
            remedyWS.Change_in_SequenceType z1G_Enable_Decision_Tree = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Change_in_SequenceType.Yes;
            bool z1G_Enable_Decision_TreeSpecified = false;
            remedyWS.Change_in_SequenceType z1G_InitComplete = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Change_in_SequenceType.Yes;
            bool z1G_InitCompleteSpecified = false;
            remedyWS.z1G_MultilanguageType z1G_Multilanguage = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1G_MultilanguageType.Enabled;
            bool z1G_MultilanguageSpecified = false;
            remedyWS.z1G_Reopen_IncidentType z1G_Reopen_Incident = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1G_Reopen_IncidentType.ReopeninCurrent;
            bool z1G_Reopen_IncidentSpecified = false;
            string z1G_Report_Server = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType z1G_Suppress_Notices = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1G_Suppress_NoticesSpecified = false;
            string z1G_WorkLog_ID = string.Empty;
            string z1G_DefaultCompany = string.Empty;
            string z1G_Global_AST_ProductionDataSetID = string.Empty;
            string z1G_Global_AST_SandBoxDataSetID = string.Empty;
            string z1G_Global_HPD_DataSetID = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType z1G_Global_SandBoxEnabled = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1G_Global_SandBoxEnabledSpecified = false;
            string z1G_HelpDeskIDPrefix = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType z1G_HPDShowDateSystem = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1G_HPDShowDateSystemSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType z1G_HPDShowFinancials = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1G_HPDShowFinancialsSpecified = false;
            remedyWS.Assigned_Group_Uses_OLAType z1G_HPDShowVendor = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool z1G_HPDShowVendorSpecified = false;
            remedyWS.z1G_TaskViewPreferenceType z1G_TaskViewPreference = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1G_TaskViewPreferenceType.Full;
            bool z1G_TaskViewPreferenceSpecified = false;
            remedyWS.z1G_UnrestrictedAccessMemberType z1G_UnrestrictedAccessMember = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1G_UnrestrictedAccessMemberType.true_1;
            bool z1G_UnrestrictedAccessMemberSpecified = false;
            remedyWS.z1G_MultilanguageType z1G_Use_Custom_Prefix = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.z1G_MultilanguageType.Enabled;
            bool z1G_Use_Custom_PrefixSpecified = false;
            string z2AF_Work_Log01_attachmentName = string.Empty;
            byte[] z2AF_Work_Log01_attachmentData = null;
            int z2AF_Work_Log01_attachmentOrigSize = 0;
            bool z2AF_Work_Log01_attachmentOrigSizeSpecified = false;
            string z2AF_Work_Log02_attachmentName = string.Empty;
            byte[] z2AF_Work_Log02_attachmentData = null;
            int z2AF_Work_Log02_attachmentOrigSize = 0;
            bool z2AF_Work_Log02_attachmentOrigSizeSpecified = false;
            string z2AF_Work_Log03_attachmentName = string.Empty;
            byte[] z2AF_Work_Log03_attachmentData = null;
            int z2AF_Work_Log03_attachmentOrigSize = 0;
            bool z2AF_Work_Log03_attachmentOrigSizeSpecified = false;
            string z2AF_Act_Attachment_1_attachmentName = string.Empty;
            byte[] z2AF_Act_Attachment_1_attachmentData = null;
            int z2AF_Act_Attachment_1_attachmentOrigSize = 0;
            bool z2AF_Act_Attachment_1_attachmentOrigSizeSpecified = false;
            string z2AF_Act_Attachment_2_attachmentName = string.Empty;
            byte[] z2AF_Act_Attachment_2_attachmentData = null;
            int z2AF_Act_Attachment_2_attachmentOrigSize = 0;
            bool z2AF_Act_Attachment_2_attachmentOrigSizeSpecified = false;
            string z2AF_Act_Attachment_3_attachmentName = string.Empty;
            byte[] z2AF_Act_Attachment_3_attachmentData = null;
            int z2AF_Act_Attachment_3_attachmentOrigSize = 0;
            bool z2AF_Act_Attachment_3_attachmentOrigSizeSpecified = false;
            string zD_ExcludeQualification = string.Empty;
            remedyWS.zD_GoalTypesType zD_GoalTypes = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.zD_GoalTypesType.EventMonitoring;
            bool zD_GoalTypesSpecified = false;
            string zD_instanceIdFrMeas = string.Empty;
            string zD_RestartWhen = string.Empty;
            remedyWS.Assigned_Group_Uses_OLAType zD_RestartYesNo = CVSA.Suporte.Sinacor.BMFBovespa.Dados.remedyWS.Assigned_Group_Uses_OLAType.No;
            bool zD_RestartYesNoSpecified = false;
            string zD_StartQualification = string.Empty;
            string zD_StopQualification = string.Empty;
            string zD_SVTInstanceID = string.Empty;
            string zD_SVTReqID = string.Empty;
            string zD_TADOccurred = string.Empty;
            string zD_TermsAndConditions = string.Empty;
            string Zip_Postal_Code = string.Empty;
            string zTmpEventGUID = string.Empty;
            string zTmpSchema2 = string.Empty;

            obj.HelpDesk_Create(AcceleratorItem1,
                        AcceleratorItem2,
                        AcceleratorItem3,
                        AcceleratorItem4,
                        AcceleratorItem5,
                        Acknowledgment_Start_Date,
                        Acknowledgment_Start_DateSpecified,
                        Additional_Location_Details,
                        Area_Code,
                        Assigned_Group,
                        Assigned_Group_ID,
                        Assigned_Group_Shift_ID,
                        Assigned_Group_Shift_Name,
                        Assigned_Group_Uses_OLA,
                        Assigned_Group_Uses_OLASpecified,
                        Assigned_Support_Company,
                        Assigned_Support_Organization,
                        Assignee,
                        Assignee_Groups,
                        Assignee_Id,
                        Assignee_Login_ID,
                        Assignee_Select_Form,
                        Assignment_Method,
                        Assignment_MethodSpecified,
                        Assignment_Accelerator,
                        Assignment_AcceleratorSpecified,
                        Association_Description,
                        Attachment_attachmentName,
                        Attachment_attachmentData,
                        Attachment_attachmentOrigSize,
                        Attachment_attachmentOrigSizeSpecified,
                        BiiARS_01,
                        BiiARS_02,
                        BiiARS_03,
                        BiiARS_04,
                        BiiARS_05,
                        bOrphanedRoot,
                        Broadcasted_Flag,
                        Broadcasted_FlagSpecified,
                        Budget_Cost__Currency_currencyValue,
                        Budget_Cost__Currency_currencyValueSpecified,
                        Budget_Cost__Currency_currencyCode,
                        Budget_Cost__Currency_currencyConversionDate,
                        Budget_Cost__Currency_currencyConversionDateSpecified,
                        Categorization_Tier_1,
                        Categorization_Tier_2,
                        Categorization_Tier_3,
                        cell_name,
                        Change_in_Sequence,
                        Change_in_SequenceSpecified,
                        CI_Tag_Number,
                        City,
                        Closed_Date,
                        Closed_DateSpecified,
                        Closure_Manufacturer,
                        Closure_Product_Category_Tier1,
                        Closure_Product_Category_Tier2,
                        Closure_Product_Category_Tier3,
                        Closure_Product_Model_Version,
                        Closure_Product_Name,
                        Closure_Source,
                        Closure_SourceSpecified,
                        Command,
                        Company,
                        Component_ID,
                        ConditionDisplay1,
                        ConditionDisplay2,
                        ConditionDisplay3,
                        ConditionDisplay4,
                        ConditionDisplay5,
                        Contact_Client_Type,
                        Contact_Client_TypeSpecified,
                        Contact_Company,
                        Contact_Sensitivity,
                        Contact_SensitivitySpecified,
                        Corporate_ID,
                        Cost_Center,
                        Country,
                        Country_Code,
                        Created_from_Template,
                        Created_from_TemplateSpecified,
                        Created_By,
                        Created_From_flag,
                        Created_From_flagSpecified,
                        CurrentStage,
                        CurrentStageNumber,
                        CurrentStageNumberSpecified,
                        DataTags,
                        Department,
                        Description,
                        Desk_Location,
                        Detailed_Decription,
                        Direct_Contact_Area_Code,
                        Direct_Contact_City,
                        Direct_Contact_Company,
                        Direct_Contact_Country,
                        Direct_Contact_Country_Code,
                        Direct_Contact_Department,
                        Direct_Contact_Desk_Location,
                        Direct_Contact_Extension,
                        Direct_Contact_First_Name,
                        Direct_Contact_Internet_Email,
                        Direct_Contact_Last_Name,
                        Direct_Contact_Local_Number,
                        Direct_Contact_Location_Details,
                        Direct_Contact_Mail_Station,
                        Direct_Contact_Middle_Initial,
                        Direct_Contact_Organization,
                        Direct_Contact_Person_ID,
                        Direct_Contact_Phone_Number,
                        Direct_Contact_Region,
                        Direct_Contact_Site,
                        Direct_Contact_Site_Group,
                        Direct_Contact_Site_ID,
                        Direct_Contact_State_Province,
                        Direct_Contact_Street,
                        Direct_Contact_Time_Zone,
                        Direct_Contact_Zip_Postal_Code,
                        DR,
                        DRSpecified,
                        Effort_Time_Spent_Minutes,
                        Effort_Time_Spent_MinutesSpecified,
                        EH,
                        EHSpecified,
                        Enable_Assignment_Engine,
                        Enable_Assignment_EngineSpecified,
                        Enable_CI_Related_lookup,
                        Enable_CI_Related_lookupSpecified,
                        Enable_CI_Warranty_Lookup,
                        Enable_CI_Warranty_LookupSpecified,
                        Escalated,
                        EscalatedSpecified,
                        Estimated_Resolution_Date,
                        Estimated_Resolution_DateSpecified,
                        Extension,
                        First_Name,
                        first_name2,
                        Flag_Create_Request,
                        Flag_Create_RequestSpecified,
                        Generic_Categorization_Tier_1,
                        Generic_Categorization_Tier_2,
                        Generic_Categorization_Tier_3,
                        GEOnet,
                        Global_OR_Custom_Mapping,
                        Group_Transfers,
                        Group_TransfersSpecified,
                        HR_ID,
                        Impact,
                        ImpactSpecified,
                        Impact_OR_Root,
                        Inbound,
                        InboundSpecified,
                        Incident_Association_Type,
                        Incident_Association_TypeSpecified,
                        Incident_Location,
                        Incident_Number,
                        Individual_Transfers,
                        Individual_TransfersSpecified,
                        InstanceId,
                        Internet_Email,
                        Last__Assigned_Date,
                        Last_Acknowledged_Date,
                        Last_Acknowledged_DateSpecified,
                        Last_Date_Duration_Calculated,
                        Last_Date_Duration_CalculatedSpecified,
                        Last_Name,
                        Last_Resolved_Date,
                        Last_Resolved_DateSpecified,
                        Last_SLA_Hold_Date,
                        Last_SLA_Hold_DateSpecified,
                        last_name2,
                        Local_Phone,
                        Login_ID,
                        LookupKeyword,
                        Mail_Station,
                        Manufacturer,
                        mc_ueid,
                        Middle_Initial,
                        Mode,
                        Next_Target_Date,
                        Next_Target_DateSpecified,
                        OLA_Hold,
                        OLA_HoldSpecified,
                        Onwer_Group_Uses_SLA,
                        Onwer_Group_Uses_SLASpecified,
                        OptionForClosingIncident,
                        Organization,
                        Original_Incident_Number,
                        Original_Last_Modified_By,
                        Original_Last_Modified_Date,
                        Original_Last_Modified_DateSpecified,
                        Outbound,
                        OutboundSpecified,
                        Owner,
                        Owner_Group,
                        Owner_Group_ID,
                        Owner_Login_ID,
                        Owner_Support_Company,
                        Owner_Support_Organization,
                        Person_ID,
                        Phone_Number,
                        policy_name,
                        PreviousStatus,
                        Priority,
                        PrioritySpecified,
                        Priority_Weight,
                        Priority_WeightSpecified,
                        Product_Categorization_Tier_1,
                        Product_Categorization_Tier_2,
                        Product_Categorization_Tier_3,
                        Product_Model_Version,
                        Product_Name,
                        ReOpened_Date,
                        ReOpened_DateSpecified,
                        Reason_Code,
                        Reason_Description,
                        Record_Type,
                        Record_TypeSpecified,
                        Region,
                        Reported_Date,
                        Reported_DateSpecified,
                        Reported_Source,
                        Reported_SourceSpecified,
                        Reported_to_Vendor,
                        Reported_to_VendorSpecified,
                        Required_Resolution_DateTime,
                        Required_Resolution_DateTimeSpecified,
                        Resolution,
                        Resolution_Category,
                        Resolution_Category_Tier_2,
                        Resolution_Category_Tier_3,
                        Resolution_Method,
                        Resolution_Start_Date,
                        Resolution_Start_DateSpecified,
                        Responded_Date,
                        Responded_DateSpecified,
                        Return_Code,
                        root_component_id_list,
                        root_incident_id_list,
                        Satisfaction_Rating,
                        Search_Bar,
                        Service_Entitlement_Method,
                        Service_Entitlement_MethodSpecified,
                        Service_Type,
                        Service_TypeSpecified,
                        Shifts_Flag,
                        Shifts_FlagSpecified,
                        Short_Description,
                        Show_For_Process,
                        Site,
                        Site_Group,
                        Site_ID,
                        SLA_Breach_Exception,
                        SLA_Breach_Reason,
                        SLA_Hold,
                        SLA_HoldSpecified,
                        SLA_Res_Business_Hour_Seconds,
                        SLA_Res_Business_Hour_SecondsSpecified,
                        SLA_Responded,
                        SLA_RespondedSpecified,
                        SLM_Priority,
                        SLM_PrioritySpecified,
                        SLM_Status,
                        SLM_StatusSpecified,
                        SLMEventLookupTblKeyword,
                        SLMLookupTblKeyword,
                        SRAttachment_attachmentName,
                        SRAttachment_attachmentData,
                        SRAttachment_attachmentOrigSize,
                        SRAttachment_attachmentOrigSizeSpecified,
                        SRID,
                        SRInstanceID,
                        SRMS_Registry_Instance_ID,
                        SRMSAOIGuid,
                        StageCondition,
                        State_Province,
                        Status,
                        StatusSpecified,
                        StatusPPL,
                        StatusPPLSpecified,
                        status_incident,
                        Status_Reason,
                        Status_ReasonSpecified,
                        status_reason2,
                        Street,
                        Submitter,
                        TemplateID,
                        TicketType,
                        TicketTypeSpecified,
                        Time_Zone,
                        Total_Cost__Currency_currencyValue,
                        Total_Cost__Currency_currencyValueSpecified,
                        Total_Cost__Currency_currencyCode,
                        Total_Cost__Currency_currencyConversionDate,
                        Total_Cost__Currency_currencyConversionDateSpecified,
                        Total_Escalation_Level,
                        Total_Escalation_LevelSpecified,
                        Total_OLA_AcknowledgeEsc_Level,
                        Total_OLA_AcknowledgeEsc_LevelSpecified,
                        Total_OLA_Resolution_Esc_Level,
                        Total_OLA_Resolution_Esc_LevelSpecified,
                        Total_Time_Spent,
                        Total_Time_SpentSpecified,
                        Total_Transfers,
                        Total_TransfersSpecified,
                        UnknownUser,
                        UnknownUserSpecified,
                        Urgency,
                        UrgencySpecified,
                        use_case,
                        Vendor_Assignment_Status,
                        Vendor_Assignment_StatusSpecified,
                        Vendor_Email,
                        Vendor_First_Name,
                        Vendor_Group,
                        Vendor_Group_ID,
                        Vendor_Last_Name,
                        Vendor_Login_ID,
                        Vendor_Name,
                        Vendor_Organization,
                        Vendor_Person_ID,
                        Vendor_Phone,
                        Vendor_Resolved_Date,
                        Vendor_Resolved_DateSpecified,
                        Vendor_Responded_On,
                        Vendor_Responded_OnSpecified,
                        Vendor_Ticket_Number,
                        VIP,
                        VIPSpecified,
                        Web_Incident_ID,
                        z1D_ACD_Phone_Number,
                        z1D_Action,
                        z1D_Action03,
                        z1D_Assign_To_Current_User,
                        z1D_Assign_To_Current_UserSpecified,
                        z1D_Assigned_Group_Role,
                        z1D_Assigned_Group_Uses_SLA,
                        z1D_Assigned_Group_Uses_SLASpecified,
                        z1D_Assignment_Change,
                        z1D_Assignment_ChangeSpecified,
                        z1D_Assoc_Action_Assc_Type01V,
                        z1D_Assoc_Action_Form01V,
                        z1D_Assoc_Description_Modified,
                        z1D_Assoc_Status,
                        z1D_Assoc_StatusSpecified,
                        z1D_Associated_CI_Related_Act,
                        z1D_Associated_Incident_Status,
                        z1D_Associated_Incident_StatusSpecified,
                        z1D_Association_Action01,
                        z1D_Association_Action01_locale,
                        z1D_Association_End_Date,
                        z1D_Association_End_DateSpecified,
                        z1D_Association_Start_Date,
                        z1D_Association_Start_DateSpecified,
                        z1D_Association_Type01,
                        z1D_Association_Type01Specified,
                        z1D_Audit_Priority,
                        z1D_Audit_Service_Type,
                        z1D_Audit_TransactionGroupNum,
                        z1D_Audit_TransactionGroupNumSpecified,
                        z1D_Audit_TransactionGroupNum1,
                        z1D_Audit_TransactionGroupNum1Specified,
                        z1D_Automatically_Associate_Customer_CI,
                        z1D_Broadcast_Action,
                        z1D_Broadcast_Number,
                        z1D_Calculate_SLM_Durations,
                        z1D_Calculate_SLM_DurationsSpecified,
                        z1D_Changeable_Reported_Date,
                        z1D_Changeable_Reported_DateSpecified,
                        z1D_Changeable_Resolved_Date,
                        z1D_Changeable_Resolved_DateSpecified,
                        z1D_Changeable_Responded_Date,
                        z1D_Changeable_Responded_DateSpecified,
                        z1D_Char01,
                        z1D_Char01NoChangeFlagV,
                        z1D_Char02,
                        z1D_Char03,
                        z1D_Char04,
                        z1D_Char05,
                        z1D_Char06,
                        z1D_Char07,
                        z1D_Char08,
                        z1D_Char09,
                        z1D_Char10,
                        z1D_Char11,
                        z1D_Char12,
                        z1D_Char13,
                        z1D_Char14,
                        z1D_Char15,
                        z1D_Char16,
                        z1D_Char17,
                        z1D_Char18,
                        z1D_Char19,
                        z1D_Char20,
                        z1D_Char21,
                        z1D_Char22,
                        z1D_Char23,
                        z1D_Char24,
                        z1D_Char25,
                        z1D_Char26,
                        z1D_Char27,
                        z1D_Char28,
                        z1D_Char29,
                        z1D_Char30,
                        z1D_Char31,
                        z1D_CI_Name,
                        z1D_CI_Number,
                        z1D_Configuration_Item_ID,
                        z1D_Copied_To_New_Flag,
                        z1D_Copied_To_New_FlagSpecified,
                        z1D_Date01,
                        z1D_Date01Specified,
                        z1D_Date02,
                        z1D_Date02Specified,
                        z1D_Date03,
                        z1D_Date03Specified,
                        z1D_Date04,
                        z1D_Date04Specified,
                        z1D_Date05,
                        z1D_Date05Specified,
                        z1D_Date06,
                        z1D_Date06Specified,
                        z1D_Default_Support_Group_ID,
                        z1D_Dialog_Action,
                        z1D_Effort_Time_Hold_Duration,
                        z1D_Effort_Time_Hold_DurationSpecified,
                        z1D_Entry_Exists,
                        z1D_Estimated_Resolution_Date,
                        z1D_Estimated_Resolution_DateSpecified,
                        z1D_Functional_Role,
                        z1D_Generated_Entry_ID_ID,
                        z1D_Hold_Status,
                        z1D_HPD_Template_ID,
                        z1D_Incident_CI_Association_Type,
                        z1D_Incident_CI_Association_TypeSpecified,
                        z1D_Incident_Number,
                        z1D_Infrastructure_Change_ID,
                        z1D_Integer01,
                        z1D_Integer01Specified,
                        z1D_Integer02,
                        z1D_Integer02Specified,
                        z1D_Integer03,
                        z1D_Integer03Specified,
                        z1D_Integer04,
                        z1D_Integer04Specified,
                        z1D_Integer05,
                        z1D_Integer05Specified,
                        z1D_Integer06,
                        z1D_Integer06Specified,
                        z1D_Just_Made_Duplicate,
                        z1D_Just_Made_DuplicateSpecified,
                        z1D_Known_Error_ID,
                        z1D_Last_Modified_DateInteger,
                        z1D_Last_Modified_DateIntegerSpecified,
                        z1D_Lastcount,
                        z1D_LastcountSpecified,
                        z1D_Lastcount02,
                        z1D_Lastcount02Specified,
                        z1D_Lock_Down_Dialog,
                        z1D_Lock_Down_DialogSpecified,
                        z1D_Lock_Down_Dialog02,
                        z1D_Lock_Down_Dialog02Specified,
                        z1D_Lock_Down_Impact_Dialog,
                        z1D_Lock_Down_Impact_DialogSpecified,
                        z1D_Locked_Down,
                        z1D_Locked_DownSpecified,
                        z1D_Max_Weight,
                        z1D_Max_WeightSpecified,
                        z1D_Message_Tag,
                        z1D_Mobile_Worklog_Upd,
                        z1D_Mode,
                        z1D_Modify_All_FlagV,
                        z1D_Modify_All_FlagVSpecified,
                        z1D_New_Description,
                        z1D_Notification_Message_Tag,
                        z1D_Notification_Type,
                        z1D_Notification_TypeSpecified,
                        z1D_NT_Functional_Role,
                        z1D_NT_Internet_Email,
                        z1D_NT_On_Call_Group_Flag,
                        z1D_NT_Pager_Message_Numeric,
                        z1D_NT_Remedy_Login_ID,
                        z1D_NT_Support_Group_ID,
                        z1D_NT_Support_Group_Shift_ID,
                        z1D_On_Call_Group_Flag,
                        z1D_On_Call_Group_FlagSpecified,
                        z1D_Original_Description,
                        z1D_Original_Incident_IAT,
                        z1D_Original_Incident_IATSpecified,
                        z1D_Original_Incident_OIN,
                        z1D_Original_Incident_Rpt_Date,
                        z1D_Original_Incident_Rpt_DateSpecified,
                        z1D_Original_StatusINC,
                        z1D_Original_StatusINCSpecified,
                        z1D_Owner_Group_Shifts_Flag,
                        z1D_Owner_Group_Shifts_FlagSpecified,
                        z1D_Parent_ID,
                        z1D_Permission_Group_ID,
                        z1D_Permission_Group_IDSpecified,
                        z1D_Permission_Group_List,
                        z1D_Prev_Assignee_Effort_Hold,
                        z1D_Prev_Assignee_Effort_HoldSpecified,
                        z1D_Prev_Assignee_Effort_Spent,
                        z1D_Prev_Assignee_Effort_SpentSpecified,
                        z1D_Prev_Assignee_Group_ID,
                        z1D_Prev_Assignee_Login_ID,
                        z1D_Prev_Assignee_Total_Effort,
                        z1D_Prev_Assignee_Total_EffortSpecified,
                        z1D_Prev_Incident_Assoc_Type,
                        z1D_Prev_Incident_Assoc_TypeSpecified,
                        z1D_Prev_Owner_Group_ID,
                        z1D_Prev_Reported_to_Vendor,
                        z1D_Prev_Reported_to_VendorSpecified,
                        z1D_Prev_StatusINC,
                        z1D_Prev_StatusINCSpecified,
                        z1D_Prev_Status_Reason,
                        z1D_Prev_Vendor_Group_ID,
                        z1D_Prev_Vendor_Resolved_Date,
                        z1D_Prev_Vendor_Resolved_DateSpecified,
                        z1D_Prev_Vendor_Responded_On,
                        z1D_Prev_Vendor_Responded_OnSpecified,
                        z1D_Previous_Operation,
                        z1D_Previous_Reported_Date,
                        z1D_Previous_Reported_DateSpecified,
                        z1D_Previous_Resolved_Date,
                        z1D_Previous_Resolved_DateSpecified,
                        z1D_Previous_Responded_Date,
                        z1D_Previous_Responded_DateSpecified,
                        z1D_Problem_Investigation_ID,
                        z1D_ReOpened_Incident_Number,
                        z1D_Report_Form_Name,
                        z1D_Report_Form_View,
                        z1D_Report_Locale,
                        z1D_Report_Name,
                        z1D_Report_Qualification,
                        z1D_Report_Target,
                        z1D_Reported_Date,
                        z1D_Reported_DateSpecified,
                        z1D_Request_Number,
                        z1D_Request_Type01,
                        z1D_Request02,
                        z1D_Required_Resolution_Date,
                        z1D_Required_Resolution_DateSpecified,
                        z1D_Run_Process_Password,
                        z1D_Run_Process_Setup,
                        z1D_Selected_Template_ID,
                        z1D_Service_Entitlement,
                        z1D_Service_EntitlementSpecified,
                        z1D_Solution_Database_ID,
                        z1D_Status,
                        z1D_StatusSpecified,
                        z1D_StatusINC,
                        z1D_StatusINCSpecified,
                        z1D_Status_Integer_Parm01,
                        z1D_Status_Integer_Parm01Specified,
                        z1D_Status_Integer_Parm02,
                        z1D_Status_Integer_Parm02Specified,
                        z1D_System_Role,
                        z1D_Table_Association_Type,
                        z1D_Table_Association_TypeSpecified,
                        z1D_Table_Request_ID,
                        z1D_Table_Request_Type,
                        z1D_Table_Request_TypeSpecified,
                        z1D_TableChar01,
                        z1D_TableChar02,
                        z1D_TableChar03,
                        z1D_Template_CI_Relation_Type,
                        z1D_Template_CI_Relation_TypeSpecified,
                        z1D_Template_Related_CI,
                        z1D_TempLocaleV,
                        z1D_Ticket_Effort_Start_Time,
                        z1D_Ticket_Effort_Start_TimeSpecified,
                        z1D_Ticket_Start_Time,
                        z1D_Ticket_Start_TimeSpecified,
                        z1D_TmpDays,
                        z1D_TmpDaysSpecified,
                        z1D_TmpHours,
                        z1D_TmpHoursSpecified,
                        z1D_TmpMinutes,
                        z1D_TmpMinutesSpecified,
                        z1D_Total_Incidents_Count,
                        z1D_Total_Incidents_CountSpecified,
                        z1D_Update_Associated_Incident,
                        z1D_Vendor_Group_ID,
                        z1D_Window_Action,
                        z1D_WorkLog_Assigned_Group,
                        z1D_WorkLog_Assignee,
                        z1D_AccerleratorAction,
                        z1D_Activity_Type,
                        z1D_Activity_TypeSpecified,
                        z1D_ActivityDate_tab,
                        z1D_ActivityDate_tabSpecified,
                        z1D_AssigneeManager,
                        z1D_AssigneeManagerLogin,
                        z1D_AssociationFormName,
                        z1D_AssociationType02,
                        z1D_AssociationType02Specified,
                        z1D_CI_InstanceID,
                        z1D_CI_Related_DateSetID,
                        z1D_ClassName,
                        z1D_CommunicationSource,
                        z1D_CommunicationSourceSpecified,
                        z1D_ContactCIAssocTblKeyword,
                        z1D_Cost_Category,
                        z1D_Cost_Type,
                        z1D_CurrentDatabaseStatus,
                        z1D_CurrentDatabaseStatusSpecified,
                        z1D_DataSetName,
                        z1D_DefaultCompanyAction,
                        z1D_DefaultCompanyActionSpecified,
                        z1D_DefaultCompanyInteger,
                        z1D_DefaultCompanyIntegerSpecified,
                        z1D_Details,
                        z1D_DisplayStatusReason,
                        z1D_HelpText,
                        z1D_Integer,
                        z1D_IntegerSpecified,
                        z1D_Local_DataSetID,
                        z1D_Namespace,
                        z1D_NotifyIndGrp,
                        z1D_NotifyIndGrpSpecified,
                        z1D_NumberOfApproval,
                        z1D_NumberOfApprovalSpecified,
                        z1D_OppositeAssociation,
                        z1D_OppositeAssociationSpecified,
                        z1D_OutageTblKeyword,
                        z1D_ParentInstanceId,
                        z1D_PrefixHolder,
                        z1D_PrefixResult,
                        z1D_Previous_Assignee_Login_ID,
                        z1D_PreviousStageNumber,
                        z1D_PreviousStageNumberSpecified,
                        z1D_Process_Id,
                        z1D_ProcessFlowAction,
                        z1D_ProcessFlowContactAction,
                        z1D_Reassign,
                        z1D_ReassignSpecified,
                        z1D_RecordType_Char,
                        z1D_RefreshContactTab,
                        z1D_RefreshFinancialsTab,
                        z1D_RefreshRelatedAssetsTab,
                        z1D_RefreshRelationshipsTab,
                        z1D_RefreshSLMTab,
                        z1D_RefreshTasksTab,
                        z1D_RefreshWITab,
                        z1D_RelationAction,
                        z1D_RequestTypeTblValue,
                        z1D_RequestTypeTblValueSpecified,
                        z1D_schemaID,
                        z1D_SchemaName,
                        z1D_Secure_Log,
                        z1D_Secure_LogSpecified,
                        z1D_Status_Reason,
                        z1D_Summary,
                        z1D_Task_Event_Code,
                        z1D_Task_Event_CodeSpecified,
                        z1D_Task_Event_Info_1,
                        z1D_Task_Event_Info_2,
                        z1D_Task_Event_Info_3,
                        z1D_Task_Event_Info_4,
                        z1D_Task_Event_Info_5,
                        z1D_Task_Event_Info_6,
                        z1D_Task_Id,
                        z1D_Task_instance_Id,
                        z1D_Task_or_Task_Group,
                        z1D_Task_or_Task_GroupSpecified,
                        z1D_Task_Read_Only,
                        z1D_Task_Read_OnlySpecified,
                        z1D_TaskSubtype,
                        z1D_TaskType,
                        z1D_TaskTypeSpecified,
                        z1D_TCOCost_currencyValue,
                        z1D_TCOCost_currencyValueSpecified,
                        z1D_TCOCost_currencyCode,
                        z1D_TCOCost_currencyConversionDate,
                        z1D_TCOCost_currencyConversionDateSpecified,
                        z1D_Triggered_Assignment,
                        z1D_Triggered_AssignmentSpecified,
                        z1D_TypeSelector,
                        z1D_TypeSelectorSpecified,
                        z1D_View_Access,
                        z1D_View_AccessSpecified,
                        z1DRefresh,
                        z1DRefreshSpecified,
                        z1G_Disable_Service_Entitlment,
                        z1G_Disable_Service_EntitlmentSpecified,
                        z1G_Enable_Decision_Tree,
                        z1G_Enable_Decision_TreeSpecified,
                        z1G_InitComplete,
                        z1G_InitCompleteSpecified,
                        z1G_Multilanguage,
                        z1G_MultilanguageSpecified,
                        z1G_Reopen_Incident,
                        z1G_Reopen_IncidentSpecified,
                        z1G_Report_Server,
                        z1G_Suppress_Notices,
                        z1G_Suppress_NoticesSpecified,
                        z1G_WorkLog_ID,
                        z1G_DefaultCompany,
                        z1G_Global_AST_ProductionDataSetID,
                        z1G_Global_AST_SandBoxDataSetID,
                        z1G_Global_HPD_DataSetID,
                        z1G_Global_SandBoxEnabled,
                        z1G_Global_SandBoxEnabledSpecified,
                        z1G_HelpDeskIDPrefix,
                        z1G_HPDShowDateSystem,
                        z1G_HPDShowDateSystemSpecified,
                        z1G_HPDShowFinancials,
                        z1G_HPDShowFinancialsSpecified,
                        z1G_HPDShowVendor,
                        z1G_HPDShowVendorSpecified,
                        z1G_TaskViewPreference,
                        z1G_TaskViewPreferenceSpecified,
                        z1G_UnrestrictedAccessMember,
                        z1G_UnrestrictedAccessMemberSpecified,
                        z1G_Use_Custom_Prefix,
                        z1G_Use_Custom_PrefixSpecified,
                        z2AF_Work_Log01_attachmentName,
                        z2AF_Work_Log01_attachmentData,
                        z2AF_Work_Log01_attachmentOrigSize,
                        z2AF_Work_Log01_attachmentOrigSizeSpecified,
                        z2AF_Work_Log02_attachmentName,
                        z2AF_Work_Log02_attachmentData,
                        z2AF_Work_Log02_attachmentOrigSize,
                        z2AF_Work_Log02_attachmentOrigSizeSpecified,
                        z2AF_Work_Log03_attachmentName,
                        z2AF_Work_Log03_attachmentData,
                        z2AF_Work_Log03_attachmentOrigSize,
                        z2AF_Work_Log03_attachmentOrigSizeSpecified,
                        z2AF_Act_Attachment_1_attachmentName,
                        z2AF_Act_Attachment_1_attachmentData,
                        z2AF_Act_Attachment_1_attachmentOrigSize,
                        z2AF_Act_Attachment_1_attachmentOrigSizeSpecified,
                        z2AF_Act_Attachment_2_attachmentName,
                        z2AF_Act_Attachment_2_attachmentData,
                        z2AF_Act_Attachment_2_attachmentOrigSize,
                        z2AF_Act_Attachment_2_attachmentOrigSizeSpecified,
                        z2AF_Act_Attachment_3_attachmentName,
                        z2AF_Act_Attachment_3_attachmentData,
                        z2AF_Act_Attachment_3_attachmentOrigSize,
                        z2AF_Act_Attachment_3_attachmentOrigSizeSpecified,
                        zD_ExcludeQualification,
                        zD_GoalTypes,
                        zD_GoalTypesSpecified,
                        zD_instanceIdFrMeas,
                        zD_RestartWhen,
                        zD_RestartYesNo,
                        zD_RestartYesNoSpecified,
                        zD_StartQualification,
                        zD_StopQualification,
                        zD_SVTInstanceID,
                        zD_SVTReqID,
                        zD_TADOccurred,
                        zD_TermsAndConditions,
                        Zip_Postal_Code,
                        zTmpEventGUID,
                        zTmpSchema2);
            inserted = true;
            return inserted;
        }

        public bool InsertIncident(Chamado chamado, byte[] arquivo, string nomedoarquivo, int tamanhoarquivo)
        {
            bool inserted = false;

            HelpDesk_Submit_Service.HPD_IncidentInterface_Create_WSService obj = new CVSA.Suporte.Sinacor.BMFBovespa.Dados.HelpDesk_Submit_Service.HPD_IncidentInterface_Create_WSService();
            HelpDesk_Submit_Service.AuthenticationInfo AuthenticationInfoValue = new HelpDesk_Submit_Service.AuthenticationInfo();

            AuthenticationInfoValue.userName = remedyUserName;
            AuthenticationInfoValue.password = Tools.Decrypt(remedyPassword, true);
            obj.AuthenticationInfoValue = AuthenticationInfoValue;
            obj.Timeout = 999999999;

            System.Net.WebProxy proxy = new System.Net.WebProxy(proxyServer, 80);
            System.Net.NetworkCredential cred = new System.Net.NetworkCredential();
            cred.Domain = "corporate";
            cred.UserName = AuthenticationInfoValue.userName;
            cred.Password = AuthenticationInfoValue.password;
            proxy.Credentials = cred;
            obj.Proxy = proxy;

            string Assigned_Group = "DO-DSE-SUPORTE NÍVEL 1";
            string Assigned_Group_Shift_Name = string.Empty;
            string Assigned_Support_Company = "BOVESPA - BOLSA DE S.PAULO";
            string Assigned_Support_Organization = "TI";
            string Assignee = string.Empty;
            string Categorization_Tier_1 = string.Empty;
            string Categorization_Tier_2 = string.Empty;
            string Categorization_Tier_3 = string.Empty;
            string CI_Name = string.Empty;
            string Closure_Manufacturer = string.Empty;
            string Closure_Product_Category_Tier1 = string.Empty;
            string Closure_Product_Category_Tier2 = string.Empty;
            string Closure_Product_Category_Tier3 = string.Empty;
            if (chamado.TipoChamado == "Duvida")
            {
                Categorization_Tier_1 = "Suporte";
                Categorization_Tier_2 = "Dúvidas Sinacor";
            }
            else
            {
                Categorization_Tier_1 = "Incidente Producao";
                Categorization_Tier_2 = "Integridade";
            }

            string Closure_Product_Model_Version = string.Empty;
            string Closure_Product_Name = string.Empty;
            string Department = string.Empty;
            string First_Name = chamado.PrimeiroNome;
            ImpactType Impact = ImpactType.Item1ExtensiveWidespread;
            bool ImpactSpecified = true;
            string Last_Name = chamado.UltimoNome;
            string Lookup_Keyword = string.Empty;
            string Manufacturer = string.Empty;
            string Product_Categorization_Tier_1 = "Software";
            string Product_Categorization_Tier_2 = "Aplicativo de Apoio";
            string Product_Categorization_Tier_3 = "Outros";
            string Product_Model_Version = string.Empty;
            string Product_Name = string.Empty;
            Reported_SourceType Reported_Source = Reported_SourceType.Web;
            bool Reported_SourceSpecified = true;
            string Resolution = string.Empty;
            string Resolution_Category_Tier_1 = string.Empty;
            string Resolution_Category_Tier_2 = string.Empty;
            string Resolution_Category_Tier_3 = string.Empty;
            Service_TypeType Service_Type = Service_TypeType.UserServiceRestoration;
            bool Service_TypeSpecified = true;
            StatusType Status = StatusType.New ;
            bool StatusSpecified = true;
            string Action = "CREATE";
            string Work_Info_Summary = "Criação do incidente";
            Create_RequestType Create_Request = Create_RequestType.No;
            bool Create_RequestSpecified = true;
            string Summary = chamado.Descricao;
            string Notes = chamado.Detalhe;
            UrgencyType Urgency = UrgencyType.Item1Critical;
            bool UrgencySpecified = true;

            string Work_Info_Notes = "Criação do incidente.";
            Work_Info_TypeType Work_Info_Type = Work_Info_TypeType.WorkingLog;
            System.DateTime Work_Info_Date = DateTime.Now;
            Work_Info_SourceType Work_Info_Source = Work_Info_SourceType.Web;
            Create_RequestType Work_Info_Locked = Create_RequestType.No;
            Work_Info_View_AccessType Work_Info_View_Access = Work_Info_View_AccessType.Public;
            string Middle_Initial = string.Empty;


            string result = obj.HelpDesk_Submit_Service(Assigned_Group,
                        Assigned_Group_Shift_Name,
                        Assigned_Support_Company,
                        Assigned_Support_Organization,
                        Assignee,
                        Categorization_Tier_1,
                        Categorization_Tier_2,
                        Categorization_Tier_3,
                        CI_Name,
                        Closure_Manufacturer,
                        Closure_Product_Category_Tier1,
                        Closure_Product_Category_Tier2,
                        Closure_Product_Category_Tier3,
                        Closure_Product_Model_Version,
                        Closure_Product_Name,
                        Department,
                        First_Name,
                        Impact,
                        Last_Name,
                        Lookup_Keyword,
                        Manufacturer,
                        Product_Categorization_Tier_1,
                        Product_Categorization_Tier_2,
                        Product_Categorization_Tier_3,
                        Product_Model_Version,
                        Product_Name,
                        Reported_Source,
                        Resolution,
                        Resolution_Category_Tier_1,
                        Resolution_Category_Tier_2,
                        Resolution_Category_Tier_3,
                        Service_Type,
                        Status,
                        Action,
                        Create_Request,
                        Summary,
                        Notes,
                        Urgency,
                        Work_Info_Summary,
                        Work_Info_Notes,
                        Work_Info_Type,
                        Work_Info_Date,
                        Work_Info_Source,
                        Work_Info_Locked,
                        Work_Info_View_Access,
                        Middle_Initial);

            inserted = true;
            return inserted;
        }
    }

}









